Say there are some elements floating around, and I'm trying to do some when I click ANYTHING(divs, body, whatever...) but the one specified (e.g. div#special).
I'm wondering if there's a better way to achieve this besides the following method I can think of...
$(document).bind('click', function(e) {
get mouse position x, y
get the element (div#special in this case) position x, y
get the element width and height
determine if the mouse is inside the element
if(inside)
do nothing
else
do something
});
$(':not(div#special)').bind('click', function(e) { ...? api.jquery.com/not-selectordiv#special...:not(div#special, div#special *)would be correct. However I would avoid binding an event handler to every element. Making use of event delegation is much better in this case.