If li has ul inside

class, javascript, jquery, list

Solution

You can use `:has()` in your selector, like this:

$("li:has(ul)").addClass("parent")

Problem

``` <ul> <li> <ul></ul> </li> <li></li> <li></li> <li></li> <li> <ul></ul> </li> </ul> ``` How do I add `class="parent"` only for `li`, which has `ul` inside it?

Original source