What is nodeName property in JavaScript HTML DOM?

The nodeName property in JavaScript is used to specify the name of a node.


You can try to run the following code to learn how to implement a nodeName property in JavaScript.

Live Demo

<!DOCTYPE html>
      <h1 id="id1">Tutorials</h1>
      <p id="id2">Demo Content</p>
      <p id="id3"></p>
      <p id="id4"></p>
         document.getElementById("id3").innerHTML = document.getElementById("id1").nodeName;
         document.getElementById("id4").innerHTML = document.getElementById("id2").nodeName;
Samual Sam
Samual Sam

Learning faster. Every day.