Archive for December, 2010

Using document.getElementById()

Posted: 2nd December 2010 by admin in programming
Tags:

With document.getElemebtById() we can have access and modify the properties of any HTML element for instance if we have the following element:

<input id="myText" type="text" />

To access all it’s properties like style or value, we just refer to the element and make the change:


<script>
document.getElementById("myText").value = "Hello";
</script>

If you put this pieces of code into a page it will not work because there is no action that call the the assigned variable, to make a proper call we should create a function or place a button if you like: