I know this has been asked several times, and I tried all the suggestions and read everything about different selectors, etc., but nothing works for me
given the following HTML snippet:
<div class="class1"> <p> <a>link</a> </p> <div class="class2 class3"> <p> <font> <a>link2</a> </font> </p> </div> </div>
I want to select the first div <a> tag, but nothing from the second div
I tried:
$('.class1').not('.class2, .class3') $('.class1').not('.class2') $('.class1').not('.class3') $(".class1:not(.class2)") $(".class1:not(.class3)") $(".class1:not(.class2, .class3)") $("div.class1:not(.class2)") $("div.class1:not(div.class2)") $("div.class1:not(div.*)")
and etc.
I donβt know if this is due to the fact that the second div has two class names or because the second div <a> tags are not direct children of the second div (for example, there are font tags and such around them), but I canβt exclude the second div.
jquery
null
source share