'appendChild()' Example : appendChild « Node Operation « JavaScript DHTML






'appendChild()' Example

 
    
<html>
<body>
<script language="javascript">
function function1(){
   var myElement = document.createElement('<div style="width:600; height:200;background-color:blue;"></div>');
   document.all.myBody.appendChild(myElement); 
} 
</script>
<body id="myBody"><button onclick="function1();">Append child</button></body>
</body>
</html>

    
      
        
  








Related examples in the same category

1.Append text node to paragraph tag