您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jQuery回车触发按钮事件(附代码)

2024/2/20 20:30:32发布22次查看
这次给大家带来jquery回车触发按钮事件(附代码),jquery回车触发按钮事件的注意事项有哪些,下面就是实战案例,一起来看一下。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"/>  <title>wjquery回车触发按钮事件</title>  <script src="jquery-1.4.2.min.js" type="text/javascript"></script>  <script language="javascript" type="text/javascript">    $(function () {      $('#submit').click(function () {        var account = $('#accountinput').val();        var password = $('#passwordinput').val();        if (account == '') {          alert('please input account.');          $('#accountinput').focus();          return false;        }        if (password == '') {          alert('please input password.');          $('#passwordinput').focus();          return false;        }        if (account == 'chad' && password == '123456') {          alert('login success.');        }        else {          alert('login failed.');        }      });      $(document).keydown(function (event) {        if (event.keycode == 13) {          $('#submit').triggerhandler('click');        }      });    });  </script></head><body>  <form id="form1" runat="server">  <p>    <table>      <tr>        <td> account</td>        <td><input id="accountinput" type="text" style="width: 150px;" /></td>      </tr>      <tr>        <td>password</td>        <td><input id="passwordinput" type="text" style="width: 150px;" /></td>      </tr>      <tr>        <td><input id="submit" type="button" value="submit"/></td>      </tr>    </table>  </p>  </form></body></html>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
如何使用android与html混合开发
css的新属性display:box使用方法
以上就是jquery回车触发按钮事件(附代码)的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product