查找所有具有用户定义的处理程序的元素 [英] Finding all elements that have a user-defined handler

查看:68
本文介绍了查找所有具有用户定义的处理程序的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript中,如何遍历HTML页面上的所有元素并找到具有用户定义的事件处理程序的元素?

In JavaScript, how can I loop through all of the elements on an HTML page and find those that have a user-defined event handler?

我正在尝试查找源代码HTML页面上所有元素的事件处理程序,但我不是原始开发人员,也无权访问原始代码。我只是页面的使用者,可以在浏览器中访问它。我想运行客户端JavaScript来识别元素(例如,在浏览器控制台中执行代码)。

I am trying to find the source code for the event handlers of all elements on an HTML page, but I am not the original developer and don't have access to the original code. I am just a consumer of the page, accessing it in a browser. I want to run client-side JavaScript to identify the elements (e.g., executing code in the browser console).

如果无法直接在JavaScript中执行此操作,是否有办法

If it's not possible to do this directly in JavaScript, is there a way to do it using a browser's JavaScript debugger?

推荐答案

打开检查器,转到元素选项卡,按Ctrl + Shift + C并单击,是否可以使用浏览器的JavaScript调试器呢?该按钮,您将在DOM中找到您的按钮,而不是在样式选项卡旁边,转到事件监听器选项卡并找到您感兴趣的ivent,在这种情况下,将单击该按钮。 检查屏幕截图

Open an inspector, go to tab Elements, press Ctrl+Shift+C and click the button, you will find your button in DOM, than beside the tab Styles, go to tab Event Listeners and find the ivent you interested, in your case, this will be click. Check screenshoot

这篇关于查找所有具有用户定义的处理程序的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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