Javascript:让用户选择像 Firebug 这样的 HTML 元素? [英] Javascript: Let user select an HTML element like Firebug?
问题描述
我想编写一个需要在网页上选择元素的浏览器 (Chrome/FF) 扩展程序.我希望它的行为像 Firebug 的元素检查器那样.单击检查箭头,然后可以悬停/突出显示元素.当您单击所需的元素时,将检查该元素.我只对允许用户选择元素的代码感兴趣 - 而不是实际检查它或任何类似的东西.
I want to write a browser (Chrome/FF) extension that needs to select an element on a web page. I would like it to behave like Firebug's element inspector does. You click the inspect arrow and you can then hover/highlight elements. When you click on the element you want, the element is inspected. I'm just interested in the code to allow a user to select an element - not in actually inspecting it or anything similar.
因为我正在编写一个扩展,如果你能提供非 jQuery/Prototype/等代码可能会很好,这样我就不必分发它了.
Because I'm writing an extension, it might be nice if you could provide non-jQuery/Prototype/etc.. code so I don't have to distribute that.
推荐答案
我使用 jQuery 作为另一个项目的组件编写了一个实现.源和文档可在此处获得:https://github.com/andrewchilds/jQuery.DomOutline
I wrote an implementation of this using jQuery as a component of another project. The source and documentation are available here: https://github.com/andrewchilds/jQuery.DomOutline
这篇关于Javascript:让用户选择像 Firebug 这样的 HTML 元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!