Get elements that are not inside of an element that has a known class
Suppose you have the following HTML code:
<div class="test">
<div class="class1">
<input type="text" data-required="true"/>
</div>
<input type="text" data-required="true"/>
</div>
I want to get all elements that have data-required attribute from .test
that are not inside of the .class1 div. So, in the example above only the
second input would be returned.
I tried:
$(".test [data-required]:not('.class1')")
but it returns the both input because :not doesn't select the parent
elements.
Is this possible with one jQuery selector?
JSFIDDLE
No comments:
Post a Comment