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






'insertBefore()' Example

<html>
<body>
<script language="JavaScript">
function function1() {
   var myElement = document.createElement('<div style="width:300; height:200;background-color:blue;"></div>');
   document.all.myDiv.insertBefore(myElement); 
} 
</script>
<button id="myButton" onclick="function1();">Insert element</button>
<div id="myDiv" style="width:300; height:200; border:solid black 1px;">
www.java2s.com
</div>
</body>
</html>

    
      
      








Related examples in the same category