Javascript examples for DOM:Element nodeName
The nodeName property returns the name of the specified node.
For an element node, the nodeName property will return the tag name.
For an attribute node, the nodeName property will return the name of the attribute.
For other node types, the nodeName property will return different names for different node types.
This property is read-only.
A String, representing the name of the node.
Possible values:
The following code shows how to get the node name of a <p> element:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <!-- My personal comment goes here.. --> <p id="demo"></p> <script> function myFunction() {/*from w w w . j a v a 2 s .com*/ var c = document.body.childNodes; var txt = ""; var i; for (i = 0; i < c.length; i++) { txt = txt + c[i].nodeName + "<br>"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>