Home  >  Article  >  Backend Development  >  jQuery回车登陆不会写

jQuery回车登陆不会写

WBOY
WBOYOriginal
2016-06-23 13:31:11714browse

小弟想做个回车登陆的效果但是老是没出效果,望大家帮忙看看问题在哪谢谢了

$(document).keyup(function(event){		if(event.keyCode ==13){		alert("1");	});


回复讨论(解决方案)

$(function() {  $(document).keyup(function(event){    if(event.keyCode ==13){      alert("1");    }  });});
这样比较好
$(function() {  $("#loginform").keyup(function(event){    if(event.keyCode ==13){      alert("1");    }  });});

如果你的alert(1)弹的出来的话,如下代码:

$("#loginform").submit();  就可以了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn