Dynamicly create DIV: var div = document.createElement("div");
Set div attributes and styles:
div.title="this is a new div.";
div. class = "newDivClass";
div.innerHTML = "Test create a div element!";
div.style.styleFloat="left";
div.style.overflow="hidden";
div.style.marginLeft="8px";
div.style.marginTop="10px";
div.style.width="320px";
div.style.height="250px";
div.style.backgroundRepeat="no-repeat";
div.style.backgroundImage="url(image/bgred.jpg)"
Add DIV to body: document.body.appendChild(div );
Set Attribute:
Add, set:
(1). div.setAttribute("ok","ok?");
html: