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
FlashApe » Create New Element function
Create New Element function
- April 22nd, 2005
- 1:14 pm