Example : How to change the style/css of html element’s using Java Script.
<!DOCTYPE html>
<html>
	<body>
		<h2>Change the style/css of HTML using js </h2>
		<div id="msg">Your Popular Website 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 Popular Website 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>Codershelpline Web site Contents</div><br>
		<div id="msg" style="display:none">Hide Contents</div><br>

		<input type="button" value="Show Contents" onclick="document.getElementById('msg')
                       .style.display='block'">
	</body>
</html>

 2,405 total views,  2 views today


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.