案例:jQuery案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/js/jquery.js"></script>
4
<script type="text/javascript">
5
i=0;
6
$(document).ready(function(){
7
  $("input").keypress(function(){
8
    $("span").text(i+=1);
9
  });
10
  $("button").click(function(){
11
    $("input").keypress();
12
  });
13
});
14
</script>
15
</head>
16
<body>
17
Enter your name: <input type="text" />
18
<p>Keypresses:<span>0</span></p>
19
<button>触发输入域的 keypress 事件</button>
20
</body>
21
</html>
22