开发者

Is there a javascript code to locate and highlight a block in a web page corresponding to its dom tree node?

开发者 https://www.devze.com 2023-02-16 21:40 出处:网络
Here I have a dom tree parsed from a html page. I want to select a node in the tree, and highlight its corresponding area in the web page (just like google chrome does, illustrated in the image below)

Here I have a dom tree parsed from a html page. I want to select a node in the tree, and highlight its corresponding area in the web page (just like google chrome does, illustrated in the image below). Is there any javascript code to implement this? I tried to wrap the selected tag with a tag, but there are some cases it didn't work. What I need is a general way. Any suggestion would be开发者_运维百科 helpful. Thank you!

Is there a javascript code to locate and highlight a block in a web page corresponding to its dom tree node?


I'd probably use a div overlay.

So you'd need to get the node's width, height and offset top and left and then overlay that with a div that has a semi-transparent background-image.

Should be fairly easy to do with jQuery

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号