我可以在 DOM 元素的所有更改上使用调试器中断吗?
我真的很希望能够看到影响特定 DOM 元素的代码。
但我也非常希望不必查看所有 javascript 来搜索可能导致问题的引用/选择器。
有没有人有一种技术可以让浏览器调试器在对特定 DOM 元素进行任何更改时中断?我不介意它需要特定的浏览器或扩展程序才能工作。
I would really love to be able to see the code that is affecting a specific DOM element.
But I also would really love not to have to look through all my javascript searching for references/selectors that might be causing the issue.
Does anyone have a technique for causing a browser debugger to break on any changes to a specific DOM element? I don't mind it requiring a specific browser or extension to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这也是不需要在 Firebug 以及 Chrome 的开发工具(也许是其他工具,没有进一步检查)中编写任何脚本的情况下实现的。
在 Firebug 中:
在 Chrome 开发者工具中
我实际上在尝试接受的999答案后发现了这一点,但是给定的代码对我不起作用。此外,Chrome 能够监视任何 DOM 子树上的事件,这似乎非常好。
This is also doable without writing any script in Firebug as well as in Chrome's developer tools (maybe others, did not inspect further).
In Firebug:
In Chrome Developer Tools
I actually found this out after trying accepted answer of 999, however given code did not work for me. Additionally, Chrome's possibility to monitor events on any DOM subtree seems really nice.
注意:以下事件在提出问题时非常有用,但已不再是最新的。推荐的替代方案是 MutationObservers,但它们仍处于成熟阶段
MDN 上的 MutationObserver< /a>
试试这个(在 Firefox 中,安装了 Firebug):
Note: The events below were great when the question was asked, but are no longer current. The recommended alternative is MutationObservers, but those are still maturing
MutationObserver on MDN
Try this (in Firefox, with Firebug installed):