Selecting certain div using jQuery

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
 
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.
 
Back
Top Bottom