If li has ul inside

<ul>
    <li>
        <ul></ul>
    </li>
    <li></li>
    <li></li>
    <li></li>
    <li>
        <ul></ul>
    </li>
</ul>

How to add class="parent"only for liwhich has ulinside it?

+3
source share
1 answer

You can use :has()in your selector, for example:

$("li:has(ul)").addClass("parent")
+15
source

Source: https://habr.com/ru/post/1778961/


All Articles