Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
How to create dynamic div using java script for Mozilla Firefox.
And how to create Div inside div
using java script for Mozilla Firefox with height width which is change dynamically on java script page.
Posted
Updated 8-Dec-10 1:27am
v2

1 solution

See following javascript function.

function create_div_dynamic(){
dv = document.createElement('div'); // create dynamically div tag
dv.setAttribute('id',"lyr1");       //give id to it
dv.className="top";                 // set the style classname
//set the inner styling of the div tag
dv.style.position="absolute";
dv.style.pixelLeft=20;
dv.style.pixelTop=100;
dv.style.pixelWidth=10;
dv.style.pixelHeight=20;
dv.style.backgroundColor="red";
//set the html content inside the div tag
dv.innerHTML='<br> hi <br>';

//finally add the div id to ur form
document.forms[0].appendChild(dv);
}


Vote up if you consider the answer suitable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900