1

I have a nested list and want to match only those <li> lines that have <ul> sub-lists.

For example in the following list I want to match cats, devious and dogs, but not playful, destructive, deadly, fast and smart.

<ul>
<li>cats
  <ul>
  <li>playful</li>
  <li>devious
    <ul>
    <li>destructive</li>
    <li>deadly</li>
    </ul>
  </li>
  </ul>
</li>
<li>dogs
  <ul>
  <li>fast</li>
  <li>smart</li>
  </ul>
</li>
</ul>

How do I do that?

Michael Große
  • 1,818
  • 1
  • 16
  • 20

1 Answers1

0

That's not possible in CSS or LESS, but if you can use JQuery, then I would do it like this:

$("li"):has("ul,li").addClass('childClass');

Hope this helps!

Ian Hazzard
  • 7,661
  • 7
  • 34
  • 60