In Association with Amazon.in   Flipkart

Tuesday, October 1, 2013

JavaScript document.getElementById() Example

document.getElementById() :- 

                                 This function is used to call the html element by tag id name then to apply some task on it. 

Example:

<head>
<script>
function style1()
{
a=document.getElementById('t1');
a.style.color="green";
a.style.backgroundColor="yellow";
a.style.padding="12px";
a.style.border="double";
a.style.borderColor="red";
}
</script>
</head>

<body>
<h2 id="t1">WELCOME TO JS DOM Functions</h2>
<input type="button" value="Apply Style" onClick="style1()" />
</body>


Output:-

WELCOME TO JS DOM Functions



No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...