Answers
Sep 12, 2006 - 06:16 AM
var newdiv = document.createElement('div');
var divIdName = 'testDiv';
newdiv.setAttribute('id',divIdName);
newdiv.style.width = "300px";
newdiv.style.height = "300px";
newdiv.style.left = "300px";
newdiv.style.top = "300px";
newdiv.style.position = "absolute";
newdiv.style.background = "#00C";
newdiv.style.border = "4px solid #000";
newdiv.innerHTML = 'Test Div';
document.body.appendChild(newdiv);
Sep 12, 2006 - 08:58 AM
Sep 13, 2006 - 12:17 PM
Test Div
Note the "display: none" which hides it initially.
When you want to show it, just execute
document.getElementById("divID").style.display = "";
You can also create copies of it in javascript and - of course - hide it again.
I think it makes it simpler to keep layout in the html file and only let javascript handle execution.
Jakob
Sep 20, 2006 - 08:25 AM
Add New Comment