Answer the question
In order to leave comments, you need to log in
How to use css selector to select an element that does NOT have a child element with the passed attribute?
Hey!
The next task is to specify a CSS selector in one test, which does not have a child element with a specific class.
For example, there is a set of elements
<div class='product'></div>
<div class='product'></div>
<div class='product'>
<div class='limited'></div>
</div>
Answer the question
In order to leave comments, you need to log in
You can add a new class and assign it to .product blocks with no .limited children using jQuery
$('.product').each(function(e){
if($(this).children('.limited').length < 1){
$(this).addClass('someSpecialClass');
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question