8

我正在寻找 jQuery 解决方案来检测mouseup窗口外。也就是说,在鼠标在窗口内被按下后,在仍然向下的同时将鼠标拖到外面,然后在外面释放,这就是事件应该触发的时间。

我试过document.mouseup = function() {}了,它没有帮助。我尝试按照此处的示例进行操作,但无法正确理解(我什至留下了评论寻求帮助,但还没有帮助..:()

4

1 回答 1

7

I have a website that uses this event and it works as you described:

$(window).on('mouseup', function(){
   //your code here
});

Note: only tested in jQuery 1.8.3, but it should work in 1.9

jsFiddle confirms. Works in jQuery 1.9.1 and 2 beta: http://jsfiddle.net/udRNx/1/

In case you didn't know, this piece of code must be placed in either $(document).ready(fn) or $(window).onload(fn).

于 2013-02-16T16:38:38.103 回答