jQuery實(shí)現(xiàn)的回車觸發(fā)按鈕事件功能示例
本文實(shí)例講述了jQuery實(shí)現(xiàn)的回車觸發(fā)按鈕事件功能。分享給大家供大家參考,具體如下:
<!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.dhdzp.com jQuery回車觸發(fā)按鈕事件</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">
<div>
<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>
</div>
</form>
</body>
</html>
運(yùn)行效果:

PS:關(guān)于javascript事件說明可參考本站javascript事件與功能說明大全:http://tools.jb51.net/table/javascript_event
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計(jì)有所幫助。
- jquery如何撲捉回車鍵觸發(fā)的事件
- jquery 綁定回車動(dòng)作撲捉回車鍵觸發(fā)的事件
- jquery實(shí)現(xiàn)回車鍵觸發(fā)事件(實(shí)例講解)
- jquery禁止回車觸發(fā)表單提交
- Jquery 監(jiān)視按鍵,按下回車鍵觸發(fā)某方法的實(shí)現(xiàn)代碼
- jquery移除、綁定、觸發(fā)元素事件使用示例詳解
- jquery實(shí)現(xiàn)input輸入框?qū)崟r(shí)輸入觸發(fā)事件代碼
- jQuery實(shí)現(xiàn)長按按鈕觸發(fā)事件的方法
- jQuery事件的綁定、觸發(fā)、及監(jiān)聽方法簡單說明
- JQuery自動(dòng)觸發(fā)事件的方法
- JQuery文本改變觸發(fā)事件如聚焦事件、失焦事件
相關(guān)文章
基于jQuery Ajax實(shí)現(xiàn)上傳文件
這篇文章主要為大家詳細(xì)介紹了jQuery Ajax上傳文件的相關(guān)代碼,需要的朋友可以參考下2016-03-03
jquery實(shí)現(xiàn)彈出層效果實(shí)例
這篇文章主要介紹了jquery實(shí)現(xiàn)彈出層效果的方法,實(shí)例分析了jQuery實(shí)現(xiàn)彈出層的技巧,涉及jQuery操作頁面元素與樣式的技巧,需要的朋友可以參考下2015-05-05
用jQuery旋轉(zhuǎn)插件jqueryrotate制作轉(zhuǎn)盤抽獎(jiǎng)
這篇文章主要為大家詳細(xì)介紹了用jQuery旋轉(zhuǎn)插件jqueryrotate制作轉(zhuǎn)盤抽獎(jiǎng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
Jquery Easyui對話框組件Dialog使用詳解(14)
這篇文章主要為大家詳細(xì)介紹了Jquery Easyui對話框組件Dialog的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12
JavaScript實(shí)現(xiàn)的滾動(dòng)公告特效【基于jQuery】
這篇文章主要介紹了JavaScript實(shí)現(xiàn)的滾動(dòng)公告特效,結(jié)合完整實(shí)例形式詳細(xì)分析了基于jQuery實(shí)現(xiàn)的頁面元素間歇修改,最終達(dá)到滾動(dòng)公告效果的相關(guān)操作技巧,需要的朋友可以參考下2019-07-07

