最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to detect a MouseUp event outside the window? - Stack Overflow

programmeradmin0浏览0评论

I am looking for jQuery solution to detect mouseup outside the window. That is, after the mouse has been downed inside the window, dragged outside while still down, and then released outside, is when the event should fire.

I tried document.mouseup = function() {}, it didn't help. I tried to follow the example here, but couldn't properly understand it (I even left a ment asking for help, but no help yet..:( )

I am looking for jQuery solution to detect mouseup outside the window. That is, after the mouse has been downed inside the window, dragged outside while still down, and then released outside, is when the event should fire.

I tried document.mouseup = function() {}, it didn't help. I tried to follow the example here, but couldn't properly understand it (I even left a ment asking for help, but no help yet..:( )

Share Improve this question edited May 23, 2017 at 12:33 CommunityBot 11 silver badge asked Feb 16, 2013 at 16:34 NedStarkOfWinterfellNedStarkOfWinterfell 5,24328 gold badges112 silver badges204 bronze badges 2
  • 4 I believe it should be document.onmouseup – Fabrício Matté Commented Feb 16, 2013 at 16:38
  • Yeah yeah, I mean that actually...:D – NedStarkOfWinterfell Commented Feb 16, 2013 at 17:09
Add a ment  | 

1 Answer 1

Reset to default 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/udRNx/1/

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

发布评论

评论列表(0)

  1. 暂无评论