jQuery .on与doubleclick事件 [英] Jquery .on with doubleclick event

查看:329
本文介绍了jQuery .on与doubleclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会起作用:

$(document).on("dblclick", "#areaA tr:has(td)", function(e) {
     //code here
 });

这不是

$("#areaA tr:has(td)").on('dblclick', function(e) {
    //Code here
});

我完全遵循jquery文档页面上的示例,但是双击不触发.当我以第一种方式进行操作时,它可以工作,但是好像它触发了两次该事件.

I'm following the example on the jquery documentation page exactly, but my double click does not fire. When I do it the first way, it works, but seems like it fires the event twice.

这是在Kendo UI网格的上下文中.

This is in the context of a Kendo UI grid.

这两段代码之间真的有区别吗?

Is there really a difference between these two pieces of code?

推荐答案

主要区别在于,每次单击时都会检查第一个条件.因此,如果动态添加内部ID为areaAtrtd的元素,则只有第一个元素可以工作.

The main difference is that the condition in the first one will be checked each time you click. So if the element with id areaA or the tr or td inside is added dynamically, only the first one can work.

这篇关于jQuery .on与doubleclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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