dcsimg
Adding an element to the DOM
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Twist_er
Posted On:   Friday, February 28, 2003 11:27 AM

I am trying to add an element to the DOM; this is what I am trying to achieve: function createElement(){: var inputNode = document.createElement('input'); inputNode.setAttribute('class', 'someClass'); inputNode.setAttribute('type', 'text'); inputNode.setAttribute('size', '120'); inputNode.setAttribute('value', 'This note is created and added to the DOM'); var posNode = document.getElementById('testdiv2'); //Instead of this I would like to add and remove the new element after the 'posNode' node posNode.appendChild(inputNode); } Can somone finish this method or guide me in the correct direction. Thank you all.    More>>

I am trying to add an element to the DOM; this is what I am trying to achieve:
function createElement(){:
var inputNode = document.createElement('input');
inputNode.setAttribute('class', 'someClass');
inputNode.setAttribute('type', 'text');
inputNode.setAttribute('size', '120');
inputNode.setAttribute('value', 'This note is created and added to the DOM');
var posNode = document.getElementById('testdiv2');
//Instead of this I would like to add and remove the new element after the 'posNode' node
posNode.appendChild(inputNode);
}
Can somone finish this method or guide me in the correct direction.
Thank you all.

   <<Less
About | Sitemap | Contact