Lets say this is my HTML:
<div id="foo">
<input id="goo" value="text" />
<span id="boo">
</span>
</div>
I would like to be able to determine what tag belongs to a html element.
Example element with id "foo" = div
, "goo" = input
, "boo" = span
...
So something like this:
function getTag (id) {
var element = document.getElementById(id);
return element.tag;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…