Skip to content Skip to sidebar Skip to footer

Dynamically Add Div To Html Page Using Javascript Or Jquery

I want to have a main div and have the ability to dynamically add new divs at the same level as the main div. Something like this:
);

or if you want the newly created <div>-s to appear before the others

$("#parent_div").prepend('<div id="created_div"></div>');

Solution 2:

$('#main').after('<div id="created_div"></div>');

Solution 3:

$('<div id="created_div"></div>').insertAfter('#main');

Post a Comment for "Dynamically Add Div To Html Page Using Javascript Or Jquery"