Example : How to change the style/css of html element’s using Java Script.
<!DOCTYPE html>
<html>
<body>
<h2>Apply the style/css to HTML using js </h2>
<div id="msg">Your Popular Website is Codershelpline</div><br>
<input type="button" value="Change1" onclick="document.getElementById('msg') .style.color='red'">
<input type="button" value="Change2" onclick="document.getElementById('msg') .style.fontSize='20px'">
</body>
</html>
Example : How to hide/display the contents of html element’s using Java Script.
<!DOCTYPE html>
<html>
<body>
<h2>Hide the contents of html using js </h2>
<div id="msg">Your Website is Codershelpline</div><br>
<input type="button" value="Hide" onclick="document.getElementById('msg') .style.display='none'">
<input type="button" value="Display" onclick="document.getElementById('msg') .style.display='block'">
</body>
</html>
Example : How to display the hide contents of html element’s using Java Script.
<!DOCTYPE html>
<html>
<body>
<h3>To show the hide contents</h3>
<div id="msg" style="display:none">Our site is Codershelpline</div><br>
<input type="button" value="Show Contents" onClick="document.getElementById('msg') .style.display='block'">
</body>
</html>
0 Comments