Get and set node background color : backgroundColor « Style « 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>








22.1.backgroundColor
22.1.1.backgroundColor
22.1.2.Get and set node background color
22.1.3.div.style.backgroundColor="#00f";