How can I ignore the class extra
for child div with class child2
?
<div class="parent extra">
<div class="child1">
Some text
</div>
<div class="child2">
Some text
</div>
</div>
The extra
class is used for translating the texts inside divs
,but I don't want to translate the child div
with class child2
. How can I filter this?
The 'extra' class is used for translating the texts inside divs,but I don't want to translate the child div with class 'child2'.How can I filter this?
$('.extra :not(.child2)')
This selector is saying
extra
child2
You can :
loop all div with parent class --> $( ".parent" ).each()
check if the current class has a class extra --> if($(this).hasClass( "extra" ){}
if the current parent class has a class extra loop all children and check if it has a child with class : child2 $(this).children().each()
and if($(this).hasClass( "child2" )){}
If it is the case get the parent and do some process...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.