A
A
Andrey Dontsov2015-11-11 16:03:51
JavaScript
Andrey Dontsov, 2015-11-11 16:03:51

jQuery. How to select an element that does not contain a nested div element with class "x"?

Hello
Question: How can I select an element that does not contain a nested div element with the class "x"?
Here's an example: jsfiddle.net/grrrkhdk

This adds a div class="done" to a container that has a div class="star", but the other way around!

We want the div class="done" to be added to containers that don't have a div class="star".
In a container that has a div class="star", nothing should be added, it should remain as it is.
Thanks for the help!!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2015-11-11
@AndreyBLG

jsfiddle.net/grrrkhdk/1
$('ul.container li:not(:has(.star))')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question