实例代码“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
  $("p, button, h1").click(function(event){
9
    $("div").html("Triggered by a " + event.target.nodeName + " element.");
10
  });
11
});
12
</script>
13
</head>
14
<body>
15
16
<h1>This is a heading</h1>
17
<p>This is a paragraph</p>
18
<button>This is a button</button>
19
<p>The heading, paragraph and button element have a click event defined. Click on each element to display which element triggered the event.</p>
20
<div style="color:blue;"></div>
21
22
</body>
23
</html>