Facebook
Banner
XMPP JavaScript Library READ MORE

Add DIV Dynamically to web page using Java Script

JavaScript, Sachin Puri, 2010-04-25 22:01:50

<HTML>
 <HEAD>
  <TITLE>Add DIV Dynamically to web page using Java Script</TITLE>
  <script>
    function addDiv()
    {
        var ele=document.createElement('div');
        ele.setAttribute('id','element');
        ele.setAttribute('style','display:block;border:1px solid;height:20px');
        document.body.appendChild(ele);
        document.getElementById('element').innerHTML="hi";
    }
  </script>
 </HEAD>

 <BODY>
  <input type="button" name="cmd" value="Add DIV" onClick="addDiv()"/>
 </BODY>
</HTML>

Note: In same way you can add other elements also to web page
Add Your Comment
   
    Yes! I want to receive all comments by email

  by Anonymous on 27-Feb-2012 01:08 pm
Thanks for the help
  • Reply
  •  3 Like
  •  2 Dislike
  • Report