Skip to Content »

FlashApe » Create New Element function

 Create New Element function

  • April 22nd, 2005
  • 1:14 pm

creating new elements and adding their attrubtes can be a little bit of a pain using the DOM…here’s a function that creates a new element, adds it’s attributes, and appends the new element to the given node:
function addNewElem (parentNode, newNodeName, attObj){
var node = document.createElement(newNodeName);
for(var p in attObj){
node.setAttribute( p “className” ? “class” : p, attObj[p]);
}
for(var i = 3; i

Want your say?

* Required fields. Your e-mail address will not be published on this site


You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>