Țaman ŞheƦzad Țaman ŞheƦzad - 3 months ago 11
HTML Question

css adjacent Sibling combinators - complected selecting

In the below code How do i go about selecting the "title" class but IF the "subnav" class exists?

<ul class="flexMenu-popup">
<li>

<a href="x" class="title">
</a>

<ul class="subnav">
</ul>

</li>
</ul>

MJH MJH
Answer

I'm not sure this is possible with CSS, but it's quite simple with jQuery:

var $ul = $('a.title', $('ul.flexMenu-popup > li > ul.subnav').parent());

if ($ul.length) {
    alert('yes');
}
else {
    alert('no');
}
Comments