quantity
quantity

Reputation: 4181

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

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!

enter image description here

Upvotes: 0

Views: 155

Answers (1)

Emmanuel
Emmanuel

Reputation: 5403

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

Upvotes: 1

Related Questions