The tagName
property returns the tag name of the element in UPPERCASE.
tagName |
Yes | Yes | Yes | Yes | Yes |
var v = element.tagName
A String type value representing the tag name of the element.
The following code shows how to get the tagName of an element.
<!DOCTYPE html>
<html>
<body>
<p id="demo">test</p>
<!--from w ww. j a v a 2 s.c om-->
<button onclick="myFunction()">test</button>
<script>
function myFunction()
{
var x=document.getElementById("demo");
x.innerHTML=x.tagName;
}
</script>
</body>
</html>
The code above is rendered as follows: