Rich Rodecker’s blog on flash, flex, actionscript, javascript, and php, with a dash of randomness
Create New Element function
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
| Print article | This entry was posted by flashape on April 22, 2005 at 1:14 pm, and is filed under DOM/Javascript. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |