Reputation: 122
Ok so I have this code but was wondering how would I exclude certain divs like for example div id="foo"
Like this
$(document (except #foo) ).click(function() {
$("#re").animate({
"margin-top": "0px"
}, 800);
$("#r").animate({
"margin-top": "0px"
}, 800);
});
Upvotes: 0
Views: 33
Reputation: 26163
Use the :not
pseudo-selector...
$("div:not(#foo)");
That will select all divs, except the one with an ID of foo.
Upvotes: 1
Reputation: 144739
You can check the target
of event object:
$(document).on('click', function(event) {
if ( $(event.target).closest('#foo').length ) return;
// ...
});
Upvotes: 1