Reputation: 18798
I have an element that has children with different classes. How can I select all elements of certain class .cellDiv
in the DOM, except those that are children of this
?
Upvotes: 0
Views: 194
Reputation: 1016
Well a good idea would be to do first an addClass to this like so
$(this).addClass('selected');
then you'll know the this has also class 'selected' then you select all withhout 'selected' class
for ....
if(!$(element).hasClass('selected')){
... select it ...
}
Upvotes: -1
Reputation: 51052
How about
$('.cellDiv').not($(this).find('.cellDiv'))
or, if you know that this
has an id, it should be faster to do
$('.cellDiv:not(#' + this.id + ' > .cellDiv')
Upvotes: 2