查找所有具有用户定义的处理程序的元素

编程入门 行业动态 更新时间:2024-10-26 20:31:35
本文介绍了查找所有具有用户定义的处理程序的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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

更多推荐

查找所有具有用户定义的处理程序的元素

本文发布于:2023-10-21 17:37:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1514903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   定义   程序   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!