W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> i=0; $(document).ready(function(){ $("input").keypress(function(){ $("span").text(i+=1); }); $("button").click(function(){ $("input").keypress(); }); }); </script> </head> <body> Enter your name: <input type="text" /> <p>Keypresses:<span>0</span></p> <button>触发输入域的 keypress 事件</button> </body> </html>