相关疑难解决方法(0)

jQuery绑定点击*ANYTHING*但*ELEMENT*

假设有一些元素漂浮在周围,当我点击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)

jquery click

68
推荐指数
3
解决办法
7万
查看次数

标签 统计

click ×1

jquery ×1