aspx Tutorial

NET Articles,jQuery demo, with jQuery, online tutorial,Jquery, SilverLight, Javascript,,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here


Get our toolbar!


Posted by Aamir Hasan   on Monday, January 31, 2011 Total Views:  

In this example, you will see how to create DIV tag programmatically using JavaScript. JavaScript DOM features are Document object, createElement method, style object, ClassName property, margin property, innerHTML property, setAttribute method, id property,document.body, appendChild method.

Here’s an example

<html xmlns="">

<head runat="server">

    <title>Create Dynamic div using javascript</title>

    <style type="text/css">



            color: #999;

            padding: 10px;

            width: 250px;

            height: 150px;

            background-color: #fafafa;

            font-size: 12px;

            font-family: verdana;

            border: solid 1px #666;



    <script type="text/javascript" language="javascript">

        function CallDiv() {

            var divTag = document.createElement("div");

   = "divDyn";

            divTag.className = "classA";

            divTag.innerHTML = "Welcome to ";






    <form id="form1" runat="server">


           <input id="btClick" type="button" value="Click" onclick="CallDiv();" />

        <br />







Download (1.06 kb)

See live demo

Category: All | Javascript
Protected by Copyscape Online Plagiarism Tool

Comments (8) -

Master Bilt Undercounter Refrigerator
Master Bilt Undercounter Refrigerator United States
11/22/2013 4:31:11 AM #

Hi there, just turned into aware of your weblog via Google, and located that it is truly informative. I'm going to watch out for brussels. I'll appreciate when you proceed this in future. A lot of other folks can be benefited from your writing. Cheers!|

Habibi United States
1/11/2014 3:11:20 PM #

I as well believe thence, perfectly pent post!.

Habibi United States
1/11/2014 3:27:51 PM #

I don�t normally have a look at these kinds of internet sites (I�m a pretty shy person) - but even though I was a bit shocked as I was reading, I was definitely a bit excited as properly. Thanks for giving me a big smile for the day

Lola Schemmel
Lola Schemmel United States
7/7/2015 6:24:43 PM #

I will right away take hold of your rss as I can't to find your email subscription link or e-newsletter service. Do you have any? Please allow me recognize so that I may just subscribe. Thanks.|

Jospeh Gelino
Jospeh Gelino United States
7/8/2015 7:18:47 PM #

I've been surfing online more than 3 hours today, yet I never found any interesting article like yours. It's pretty worth enough for me. In my view, if all web owners and bloggers made good content as you did, the net will be a lot more useful than ever before.|

s Tunisia
9/2/2015 8:13:51 AM #


honest psychic
honest psychic United States
9/10/2015 7:59:53 PM #

Retroplanet has an online purchasing facility for retro vacation cards. Retroplanet is a good place to find retro greeting playing cards and Christmas cards. It is often known as ESP or Additional Sensory Perception.

Victor United States
10/4/2015 2:28:44 PM #

Excellent items from you, man. I have keep in mind your stuff prior to and you are simply too magnificent. I actually like what you've acquired here, certainly like what you're stating and the best way by which you assert it. You are making it enjoyable and you still care for to stay it sensible. I can't wait to read far more from you. That is actually a great site.|

sdorttuiiplmnr United States
12/5/2015 11:19:31 PM #

hello there and thank you for your information – I’ve definitely picked up anything new from right here. I did however expertise some technical points using this web site, since I experienced to reload the web site many times previous to I could get it to load properly. I had been wondering if your web hosting is OK? Not that I'm complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your quality score if ads and marketing with Adwords. Well I’m adding this RSS to my email and could look out for a lot more of your respective exciting content. Make sure you update this again very soon..

Add comment

  Country flag

  • Comment
  • Preview

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5