js监听键盘回车

//监听回车

$(document).keydown(function(e) {
   if (e.keyCode == 13) {
   $("#btnLogin").click();
   }
})

//input绑定回车

$('#dataInput').bind('keypress',function(event){
    if(event.keyCode == "13")    
     {
       alert('你输入的内容为:' + $('#dataInput').val());
     }
});

 

posted @ 2015-08-13 07:26  BloggerSb  阅读(458)  评论(0编辑  收藏  举报