30 Mar 2010 at 15:34 #1 ultim ultim Associate Joined 6 Jan 2006 Posts 1,024 Location Midlands Hi, I have a dynamic page and i would like to use jquery to hide certain divs. Is it possible to hide all <div> which do not have a <h2> tag as one of its children? Thanks
Hi, I have a dynamic page and i would like to use jquery to hide certain divs. Is it possible to hide all <div> which do not have a <h2> tag as one of its children? Thanks
30 Mar 2010 at 17:27 #2 Tripnologist Tripnologist Soldato Joined 12 May 2007 Posts 3,896 Location Bristol You'd need to have a specific # to target to do it in but this would work. $('#id div').children(':not("h2")').parent().hide(); in div#id, find all divs. Find the children of those divs which are not h2, then jump to the parent div and hide it.
You'd need to have a specific # to target to do it in but this would work. $('#id div').children(':not("h2")').parent().hide(); in div#id, find all divs. Find the children of those divs which are not h2, then jump to the parent div and hide it.