利用jQuery要了解对谁做事件,做什么事件、怎样做事件
下例为点击一个div改变背景颜色的代码
在这里插入代码片<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box1 {
width: 200px;
height: 200px;
background-color: red;
}
.box2 {
width: 300px;
height: 300px;
background-color: blue;
}
</style>
<script src="js/jquery-1.10.2.js"></script>
<script>
$(function(){
$(".box1").click(function(){
$(this).css({backgroundColor:"blue"})
}
)
})
</script>
</head>
<body>
<div class="box1"></div>
</body>
</html>