'dom.createElement'에 해당되는 글 1건

  1. 2007.04.17 createElement

createElement

카테고리 없음 2007. 4. 17. 00:38
When you create an element you must append it to something inside the HTML document to give it scope (visibility). // this code does NOT work


newdiv = document.createElement("div"); // set div attributes newdiv.className = "x"; newdiv.id = "mine"; ... mydiv = document.getElementById("mine"); // does not find it

////////////////////////////

//this code DOES work

newdiv = document.createElement("div"); // set div attributes newdiv.className = "x"; newdiv.id = "mine";
document.body.appendChild(newdiv); // or some other node ... mydiv = document.getElementById("mine"); // finds it

http://www.zytrax.com/tech/dom/createelement.html)