Reputation: 477
Is there a way to use multiple variables inside a .not()
selector in jQuery?
e.g.
var target = $('.custom-element') // This must be in a variable
$('.element').not(this, target).toggleClass('visible');
Upvotes: 0
Views: 57
Reputation: 8513
You might also try this, for simplicity's sake. CSS rules allow for comma separated selectors:
var target = $('.custom-element') // This must be in a variable
$('.element, .custom-element').not(this).toggleClass('visible');
Upvotes: 0
Reputation: 133403
You can't pass multiple parameters to .not()
. However you can chain them
$('.element').not(target).not(this).toggleClass('visible');
You can use .add()
to add the element this
to existing group then it can used.
var target = $('.custom-element') ;
$('.element').not(target.add(this)).toggleClass('visible');
Upvotes: 1