本文介绍了jQuery:当`dblclick`即将到来时,抑制`click`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个< span> 。当您单击此跨度时,我想要一个 save()函数来触发。当双击跨度时,我想要一个 rename()函数触发。



点击跨度,然而,首先,点击事件将触发,然后$ code> dblclick 事件。由于点击 dblclick 之前,我该如何告诉点击没有开始 save(),而是依照 dblclick 其中 rename()将被触发?



我可以想出几个解决方法,但是jQuery或以前(代码)中的任何现有功能可以帮助我这个已经吗?

解决方案

这看起来很有帮助:


Let's say I have a <span>. When you single-click this span, I want a save() function to fire. When you double-click the span, I want a rename() function to fire.

If you double-click the span, however, first the click event will fire, then the dblclick event. Since the click precedes dblclick, how can I tell click to not fire save() and instead defer to dblclick where rename() will be fired?

I can probably come up with a few workarounds, but is there any existing functionality in jQuery or previous (code) work that helps me with this already?

解决方案

This looks helpful:single and double-click

这篇关于jQuery:当`dblclick`即将到来时,抑制`click`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 08:18