Tutorial Asas J...LOGIN

Tutorial Asas Javascript: Tunjukkan dan Sembunyikan Contoh

Contoh

Kodnya adalah seperti berikut:

<!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>


bahagian seterusnya
<!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>
babperisian kursus