假设有一些元素漂浮在周围,当我点击ANYTHING(divs,body,等等......)但是指定的那个(例如div#special)时,我正试图做一些.
我想知道是否有更好的方法来实现这一点,除了我能想到的以下方法......
$(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
});
Run Code Online (Sandbox Code Playgroud)