mouseup没有被正确检测

mouseup没有被正确检测

本文介绍了jQuery mouseup没有被正确检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含跨度的div。我有一个mouseup,和mousedown事件,应该触发时按下div。但是它不能正常工作。



请转到这个小提琴:



如果您选择文字,然后尝试拖动它,它只会检测到mousedown事件,但是不是mouseup。



我做错了什么?我正在使用Chrome。



谢谢



编辑:



对不起,我简化了问题,看到新的小提琴。

解决方案

正在检测到事件;只是在执行拖动后浏览器未触发mouseup事件。这是浏览器的故意行为。如果你想要包括你现在打算的行为,你也应该听这个dragend事件。


I have a div that contains a span. I have a mouseup, and mousedown event that should fire when pressing in the div. However it doesn't work correctly.

Please go to this fiddle: http://jsfiddle.net/Ym7rM/

If you select the text and then try to drag it, it just detects the mousedown event,but not the mouseup.

What am I doing wrong? I'm using Chrome.

Thanks

EDIT:

Sorry, I simplified the question, see the new fiddle.

解决方案

The mouseup event is being detected correctly; it's just that the browser is not firing a mouseup event after you perform a drag. This is an intentional behavior by the browser. You should also listen for the dragend event if you want to include the behavior that you are intending now.

这篇关于jQuery mouseup没有被正确检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:42