I have an element that has children with different cla开发者_JAVA百科sses. How can I select all elements of certain class .cellDiv
in the DOM, except those that are children of this
?
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')
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 ...
}
精彩评论