实例代码“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
i=0;
8
$(document).ready(function(){
9
  $("p").keypress(function(){
10
    $("span").text(i+=1);
11
  });
12
  $("button").click(function(){
13
    $("p").keypress();
14
  });
15
});
16
</script>
17
</head>
18
<body>
19
20
<p>Keypresses: <span>0</span></p>
21
<button>Trigger the keypress event</button>
22
23
</body>
24
</html>