keypress调用了两次

			$(document).ready(function(){
				$(document).keypress(function(e){//监听键盘按键
					//alert(e.which);
					/** 此处会导致两次login();
					switch(e.which){
						case 13:{//Enter键
							login();
							break;
						}
					}
					*/
					if (e.which == "13") {
						login();
						return false;
					}
				});
			});

上面代码在火狐中有问题,所以做出如下更改:把其中的替换为

				$(document).keydown(function(e){ 
					var curKey = e.which; 
					if(curKey == 13){ 
						login();
						return false; 
					} 
				}); 


猜你喜欢

转载自blog.csdn.net/u012138706/article/details/38333617
今日推荐