HTML DOM nodeName Property

The nodeName property returns the name of the specified node. For example if the node is an element node, then the nodeName will returns the tag name and if the node is an attribute node, then it returns the name of attribute. The syntax of nodeName is as follows :
  node.nodeName
Example :
<html>
<body>
  <p id="demo" class="paragraph" style="color: blue;">Hello world</p>
  <p>The NodeName is : <b><span id="echo"></span></b></p>
  <script>
    var name = document.getElementById("demo").nodeName;
    document.getElementById("echo").innerHTML = name;
  </script>
</body>
</html>
Output :

Hello world
The NodeName is :


Next Topic :