Javascript Get Elements Tag

    Table of contents

javascript get element's tag

Tags: javascript , html , tags Answers: 1 | Viewed 72,065 times

Lets say this is my HTML:

<div id="foo">
<input id="goo" value="text" />
<span id="boo">

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;

Some Answers For Javascript Get Elements Tag

Please leave your answer here: