html回车事件

 1 <!DOCTYPE html>

 2 <html xmlns="http://www.w3.org/1999/xhtml">

 3 <head>

 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

 5     <title></title>

 6     <script src="../js/jquery-1.10.2.js"></script>

 7     <script type="text/javascript">

 8         $(document).ready(function () {

 9             $('#dataInput').bind('keypress', function (event) {

10                 if (event.keyCode == "13") {

11                     alert('你输入的内容为:' + $('#dataInput').val());

12                 }

13             });

14         });

15 

16         function dia()

17         {

18             if (event.keyCode == 13) {

19                 alert('你输入的内容为:' + $('#dialog').val());

20             }

21         }

22     </script>

23 </head>

24 <body>

25     <input id="dataInput" type="text" />

26     <input id="dialog" type="text" onkeypress="dia()" />

27 </body>

28 </html>

 

你可能感兴趣的:(html)