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

jQuery实现的回车触发按钮事件功能示例

2024/6/28 2:09:05发布38次查看
这篇文章主要介绍了jquery实现的回车触发按钮事件功能,涉及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>www.jb51.net jquery回车触发按钮事件</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>
运行效果:
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
vue-cli axios请求方式及跨域处理问题
浅谈react高阶组件
vue数据控制视图源码解析
以上就是jquery实现的回车触发按钮事件功能示例的详细内容。
该用户其它信息

VIP推荐

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