gibney.org : Technology : Javascript : Repository : dynamic_html_elements


just a logo :)

search:


See as: raw | code

terms of service | imprint

gibney.org
is powered by m1d1





dynamic_html_elements
(Entry Nr. 88, by user 1 | edit)
// functions for the dynamic creation and deletion of html elements function removeElementById(id) { if (!document.getElementById(id)) return; element=document.getElementById(id); element.parentNode.removeChild(element); } function appendElementToBody(element,id) { var newElement=document.createElement(element); newElement.id=id; document.getElementsByTagName('body').item(0).appendChild(newElement); return newElement; } // special functions for divs function removeDiv(id) { removeElementById(id); } function createDiv(id,posX,posY,content) { var menuDiv=appendElementToBody('div',id); menuDiv.style.position='absolute'; menuDiv.style.top =posY+'px'; menuDiv.style.left=posX+'px'; menuDiv.innerHTML=content; return menuDiv; /* old version var menuDiv=document.createElement("div"); menuDiv.id=id; menuDiv.style.position='absolute'; menuDiv.style.top =posY+'px'; menuDiv.style.left=posX+'px'; menuDiv.innerHTML=content; document.getElementsByTagName('body').item(0).appendChild(menuDiv); return menuDiv; */ }
Create a new entry at this position