Javascript Basi...LOGIN

Javascript Basics Tutorial: Show and Hide Examples

Example

The code is as follows:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>事件</title>
	<style type="text/css"> 
		div{
			width:150px;height:150px;background:#f60;
		}
	</style>	
</head>
<body>
		<div id="dv"></div><br>

		<input type="button" value="隐藏" onclick="bt()">
		<input type="button" value="显示" onclick="bt1()">

		<script type="text/javascript">
			function bt(){
				var div=document.getElementById("dv");
	        	div.style.display="none";
			}
			function bt1(){
				var div=document.getElementById("dv");
	        	div.style.display="block";
			}
		</script>
</body>
</html>


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>事件</title> <style type="text/css"> div{ width:150px;height:150px;background:#f60; } </style> </head> <body> <div id="dv"></div><br> <input type="button" value="隐藏" onclick="bt()"> <input type="button" value="显示" onclick="bt1()"> <script type="text/javascript"> function bt(){ var div=document.getElementById("dv"); div.style.display="none"; } function bt1(){ var div=document.getElementById("dv"); div.style.display="block"; } </script> </body> </html>
submitReset Code
ChapterCourseware