简体   繁体   English

如何判断哪些事件绑定到DOM元素?

[英]How can I tell what events are bound to a DOM element?

When using the Wordpress visual editor, if you have a [gallery] shortcode, in visual mode it is presented with a placeholder. 使用Wordpress可视化编辑器时,如果您有[gallery]短代码,则在可视模式下会显示一个占位符。

Clicking the placeholder will overlay two icons - edit gallery and remove gallery. 单击占位符将覆盖两个图标 - 编辑库和删除库。

I'm trying to figure out what function fires when 'edit gallery' is clicked. 我正在试图找出点击“编辑图库”时触发的功能。

The button is an image, with the dom id wp_editgallery , and this is how it looks: 该按钮是一个图像,dom id为wp_editgallery ,它的外观如下:

截图与 -  shadow.png

My instincts are to inspect the element using Chrome's web inspector: 我的直觉是使用Chrome的网络检查器检查元素:

After finding the element, I check out the properties panel and look for events, but the results are somewhat cryptic: 找到元素后,我查看属性面板并查找事件,但结果有点神秘:

截图与 -  shadow.png

So far I've tried the above method, and also: 到目前为止,我已经尝试了上述方法,并且还:

var events = jQuery._data('#wp_editgallery', 'events');

As was recommended in How to see what exact events are bound to DOM elements? 正如在如何查看绑定到DOM元素的确切事件中所建议的那样 I also tried using Visual Event as was mentioned in that post - both without success. 我也试过使用Visual Event文章中提到的Visual Event - 两者都没有成功。

Is there an easier way of find out what javascript function is tied to an DOM element's event listener? 有没有更简单的方法来找出javascript函数绑定到DOM元素的事件监听器?

check out Visual Event . 看看视觉事件 Works awesome with Chrome! 与Chrome一起工作真棒! Lets you view and run the events attached to DOM elements. 允许您查看和运行附加到DOM元素的事件。 Has been a life saver! 一直是救命的人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何仅使用JavaScript,不使用框架来访问绑定到dom元素的事件 - How do I access what events have been bound to a dom element using only JavaScript, no frameworks 我如何判断一个元素是否在影子 DOM 中? - How can I tell if an element is in a shadow DOM? 如何判断一个元素是 jquery DOM 元素还是原版? - how can I tell if an element is a jquery DOM element or vanilla? 如何判断 DOM 元素在当前视口中是否可见? - How can I tell if a DOM element is visible in the current viewport? 我可以使用 jQuery 找到绑定在元素上的事件吗? - Can I find events bound on an element with jQuery? 如何查看与DOM元素绑定的确切事件? - How to see what exact events are bound to DOM elements? 在javascript中,如何在不调用函数的情况下告诉它绑定到哪个对象(即其“ this”)? - In javascript, how can I tell what object a function is bound to (ie, its 'this') without calling it? jQuery:我可以获得对元素绑定事件的引用吗? - jQuery: Can I get a reference to the bound events on an element? 如何判断 Blazor 何时完成渲染 DOM 元素? - How can I tell when Blazor has finished rendering a DOM element? 如何通过live()获得有关绑定到元素的事件的信息? - How can I get information about events that are bound to an element via live()?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM