Get node name : Introduction « DOM Node « JavaScript Tutorial






<html>
<head>
<title>The Node</title>
<script type="text/javascript">

function outputNodeProps(nd) {
   var strNode = "Node Type: " + nd.nodeType;
   strNode += "\nNode Name: " + nd.nodeName;
   strNode += "\nNode Value: " + nd.nodeValue;

   if (nd.style) {
      var clr = "red";
      nd.style.backgroundColor=clr;
      strNode += "\nbackgroundColor: " + clr;
   }
   alert(strNode);

}
</script>
<body onload="outputNodeProps(document)">
<div id="div1">
<h1>Header</h1>

</div>
</body>
</html>








23.1.Introduction
23.1.1.InnerText and InnerHTML
23.1.2.Get node type
23.1.3.Get node name
23.1.4.Get node value