Javascript basic tutorial event small example

Small example of Javascript event:

Change the color of the div by clicking the button

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

		<input type="button" value="点击" onclick="bt()">

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


Continuing Learning
||
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css"> div{width:150px;height:150px;border:1px solid #f60;}</style>
</head>
<body>
<div id="dv"></div><br>
<input type="button" value="" onclick="bt()">
<script type="text/javascript">
function bt(){
var div=document.getElementById("dv");
div.style.backgroundColor="red";
}
</script>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
submitReset Code
图片放大关闭