'mouseup'和'click'事件有什么区别? [英] What's the difference between 'mouseup' and 'click' events?

查看:119
本文介绍了'mouseup'和'click'事件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery,我经常喜欢将 mousedown mouseup 事件与可推送按钮结合使用。

Using jQuery, I often like to use mousedown and mouseup events in conjunction for pushable buttons.

然而,在每种情况下我都使用 mouseup 事件,绑定点击事件似乎产生相同的结果。

However, in every case I've used the mouseup event, binding the click event instead seemed to produce identical results.

以下两种方法之间是否存在实质性差异?

Is there any substantial difference between the two methods below?

// Method 1
$('.myButton').bind('click', callback);

// Method 2
$('.myButton').bind('mouseup', callback);

请注意我正在寻求关于使用这两种方法之间差异的技术解释。这与被标记为欺骗的问题无关:区分点击vs mousedown / mouseup

推荐答案

使用mouseup事件,您可以单击屏幕上的其他位置,按住单击按钮,并将指针移动到鼠标元素,然后释放鼠标指针。

With a mouseup event, you can click somewhere else on the screen, hold down the click button, and move the pointer to your mouseup element, and then release the mouse pointer.

点击事件需要在该元素上发生mousedown和mouseup事件。

A click event requires the mousedown and mouseup event to happen on that element.

正常的期望是点击需要mousedown和mouseup事件,所以我建议点击事件。

The normal expectation is that a click requires both the mousedown and mouseup event, so I'd recommend the click event.

从可能的重复,似乎也可能导致mouseup和mousedown事件通过左键单击按钮以外的鼠标按钮。这与普通用户期望的非常不同。

From the possible duplicate, it appears that mouseup and mousedown events can also be caused by mouse buttons other than the left click button. Which is very different from what a generic user would expect.

这篇关于'mouseup'和'click'事件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆