在jQuery中都有mousedown / mouseup和dblclick [英] Having both mousedown/mouseup and dblclick in jQuery

查看:322
本文介绍了在jQuery中都有mousedown / mouseup和dblclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当一个mousedown或mouseup处理程序附加到一个元素,dblclick不能被附加(如果附加,将不起作用),尽管这似乎是足够的,有没有办法恢复dblclick功能,而无需从头开始重写(叹息)。 ..)
或者我缺少有关事件传播的东西?

Whenever a mousedown or mouseup handler is attached to an element the dblclick cannot be attached (won't work if attached), though this seems fair enough is there any way to reinstate a dblclick functionality without rewriting it from scratch (sigh...) Or am I missing something about events propagation?

推荐答案

它的工作原理 - 将此代码放在Firebug中这个页面,你会看到它工作(尝试双击你的问题的文本):

It works - place this code in Firebug on this very page and you'll see it working (try double clicking on the text of your question):

($('.post-text')
    .mousedown(function () { console.log('down'); })
    .mouseup(function () { console.log('up'); })
    .dblclick(function () { console.log('dbclick'); }));






没有 Firebug ?去抓住它,我会等等!


Don't have Firebug? Go grab it, I'll wait!

这篇关于在jQuery中都有mousedown / mouseup和dblclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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