Sunday, 22 June 2014

Javascript getElementById Method

—  The most common way to access an HTML element is to use the id of the element.
—  The “innerHTML” property is useful for getting or replacing the content of HTML elements.

Example:-

<html>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello World!";
document.getElementById("demo").style.backgroundColor = "red";
</script>
</body>
</html>