Saturday, 30 March 2013

Manipulating HTML Elements


How to access an HTML element from JavaScript :

Using document.getElementById(id) method.

document.getElementById("demo").innerHTML="Test code";

Simple example :

<!DOCTYPE html>
<html>
<body>
<div  id="Test">Test Code</p>
<script>
document.getElementById("demo").innerHTML="Test code";
</script>
</body>
</html>

Output :
Test code

No comments:

Post a Comment