16 Kasım 2010 Salı

Today, I was working on constructing a dynamic web page that allows user to add new paragraphs or links dynamically.

Here the basic way to add new elements to the webpage dynamically.



//we create a new paragraph element
newParag = document.createElement('p');
//we create a new text node
newText = document.createTextNode("Here the new paragraph");
//we add the text node inside the newly created paragraph element
newParag.appendChild(newText);
//Assume we have a division that has id 'content' and we
//call the 'content' division and add new paragraph to it
document.getElementById('content').appendChild(newParag);


That's all. Have a good life... see you:)

Hiç yorum yok:

Yorum Gönder