1 <!DOCTYPE html>
2 <html>
3
4 <head>
5 <meta charset="utf-8" />
6 <title></title>
7 <script type="text/javascript">
8 window.onload = function() {
9 var items = document.getElementsByTagName("p");
10 for(var i = 0; i < items.length; i++) {
11 items[i].onclick = function() {
12 alert("suc!");
13 }
14 }
15
16 };
17 </script>
18 </head>
19
20 <body>
21 <p>测试1</p>
22 <p>测试2</p>
23
24 </body>
25
26 </html>