Monday, 23 August 2010

getElementById(ID)

Sometimes you want to be able to select a particular element from a web page. The getElementById(ID) JavaScript document object function returns the element whose ID is specified.

This simply lets you select any element from a document providing the means to perform an operation on that element. 

Some example JavaScript:
document.getElementById('div1').style.color = 'blue';
document.getElementById('input1').value = newvalue;

The id on the tag must be set:
<div id="div1"></div>
<input id="input1" type="text" />

No comments:

Post a Comment