最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery按回車提交數(shù)據(jù)的代碼示例

 更新時間:2013年11月05日 16:01:37   作者:  
jquery按回車提交數(shù)據(jù)的代碼示例,很簡單的一個方法,看一下就明白
其實(shí)jquery按回車提交數(shù)據(jù)是很簡單的事情,我們只要檢查測到用戶按了回車就直接綁定事件.click就實(shí)現(xiàn)了提交了,在按鈕上我們綁定ajax提交表單事件即可。
核心代碼
 
復(fù)制代碼 代碼如下:

$(document).ready(function(){
$("按下回車的控件").keydown(function(e){
var curKey = e.which;
if(curKey == 13){
$("#回車事件按鈕控件").click();
return false;
}
});
});
 

是用js的ajax功能同時支持回車事件
復(fù)制代碼 代碼如下:

document.onkeydown = function (e) {
var theEvent = window.event || e;
var code = theEvent.keyCode || theEvent.which;
if (code == 13) {
$("#login_submit").click();
}


$(document).ready(function() {
    //登錄提交
    $("#login_submit").bind('click',function(){
        var username=$("#username").val();
        var password=$("#password").val();

        $.ajax({
                type : 'POST',
                url : './login.php',
                data: {type :'ajax',username:username,password:password},
                success : function(msg){
                    //alert(msg);
                    if(msg==-1){
                        alert('用戶名不能為空');
                        $("#username").focus();
                    }
                    if(msg==-2){
                        alert('用戶名不存在');
                        $("#username").val("");
                        $("#username").focus();
                    }
                    if(msg==-3){
                        alert('密碼不能為空');
                        $("#password").focus();
                    }
                    if(msg==-6){
                        alert('密碼輸入不正確');
                        $("#password").focus();
                    }
                    if(msg==1){
                        //alert('登錄成功');
                        window.location.href='./index.php';
                    }

                }
            });
    });

});
 

相關(guān)文章

最新評論

邳州市| 仁寿县| 清丰县| 清流县| 阿城市| 涞水县| 霍山县| 辛集市| 荥经县| 汉川市| 剑河县| 新昌县| 惠水县| 道孚县| 马边| 当涂县| 都安| 大洼县| 新疆| 中西区| 新疆| 宿松县| 河北省| 星座| 连南| 商城县| 新龙县| 万安县| 广水市| 张家港市| 邛崃市| 垦利县| 杨浦区| 湾仔区| 潼南县| 新兴县| 全南县| 清原| 景宁| 宝清县| 新河县|