javascript - 如何在 jQuery 中使用事件捕获概念 this._on();

标签 javascript jquery html

我正在使用 jQuery this._on() 函数来绑定(bind)鼠标事件,我想在 this._on() 中使用事件捕获概念。

this._on($("#myId"), "mousedown", callMouseDown);

callMouseDown: function (e) {
    //Mouse down event
},

任何人都可以帮助我,这里如何应用事件捕获概念(父级到子级)。

谢谢, 巴拉蒂。

最佳答案

使用 this 访问您的方法。

this._on($("#myId"), "mousedown", this.callMouseDown);

callMouseDown: function (e) {
    //Mouse down event
},

更新:

jQuery 事件不支持事件捕获。但它支持事件冒泡。

请查看以下链接了解更多信息

Why does jQuery event model does not support event Capture and just supports event bubbling

关于javascript - 如何在 jQuery 中使用事件捕获概念 this._on();,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33273591/

相关文章:

javascript - 并在 Parse Cloud 代码上查询

javascript - React 应用程序中的 Vega-tooltip

javascript - 将 JSON 数据从 php 传递到 html-data 属性,然后传递到 Javascript

css - 如何让页脚停留在网页底部?

javascript - JS性能: why don't load uninitialized or deleted elements

javascript - 'async' 修饰符不能在 typescript react 中使用

javascript - Ajax上传仅将第一个文件传递给php文件

jquery - 手动定位 Fancybox 2

javascript - jQuery cookie 破坏了我的 CSS 切换输入

java - 将 JTextPane 设置为内容类型 HTML 并使用字符串生成器