AJAX Example Creating New Dynamic HTML Elements With Javascript

This is a simple example to create dynamic HTML elements in a browser.

var newDiv, newTextField, newText;
newDiv = document.createElement('div');
newDiv.id = 'NewDiv';
newTextField = document.createElement('input');
newTextField.type = 'text';
newTextField.value = 'Hello';
newText = document.createTextNode('Text Here:');

The example is from the book “AJAX Bible” by Steven Holzner. The methods used in the example are defined by W3C DOM Core Level 1.


About minghuasweblog

a long time coder
This entry was posted in AJAX and Webapp, All and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s