plain javascript code to highlight an html element

to debug some javascript code, I am looking for javascript code (preferably just js, without libraries and dependencies) that can highlight a div or span (probably by putting over it a div or span of the same size and shape with a bright color and some transparency).

I pretty sure it can be done, but I don’t know how to start.

CLARIFICATION

I need to put a semi transparent div on top of my element. Modifying the background or adding borders will not help as my elements have themselves backgrounds and borders.

74 thoughts on “plain javascript code to highlight an html element”

Leave a Comment