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:-
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:-
No comments:
Post a Comment