实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
5
</script>
6
<script>
7
$(document).ready(function(){
8
  $("div").on("click","button",function(event){
9
    $(event.delegateTarget).css("background-color", "pink");
10
  });
11
});
12
</script>
13
</head>
14
<body>
15
16
<div style="background-color:yellow">
17
<p>Click the button to change the background color of this div.</p>
18
<button>Click me!</button>
19
</div>
20
21
<div style="background-color:yellow">
22
<p>Click the button to change the background color of this div.</p>
23
<button>Click me!</button>
24
</div>
25
26
</body>
27
</html>