Skip to content Skip to sidebar Skip to footer

Css Selector (or Javascript If Needed) For Select Div's Which Contain At Least One Ul

Suppose I have a hierarchy like this:
Copy

Note: If you are using some dynamic language on the server, such as PHP, this could actually be implemented fairly easily, without manual coding.

Or if you want to be dynamic I recommend jQuery:

$("div > ul").parent().addClass("div_with_ul_class");

Solution 2:

Parent selector isn't available in CSS, despite a lot of requests to add it.

jQuery has a nice selector, know as :has; http://api.jquery.com/has-selector/

$('div:has(ul)');

Would be the jQuery selector.

Post a Comment for "Css Selector (or Javascript If Needed) For Select Div's Which Contain At Least One Ul"