js 把回车转换成tab键 火狐浏览器怎么实现

在IE下用
function tabChanger() {
if (event.keyCode == 13)
event.keyCode = 9;
}这样的函数就能实现这个功能,
但是在火狐下面
function tabChanger() {
if (e.keyCode == 13)
e.keyCode = 9;
}这样的函数好像没有效果,求高手指点。

  您好!很高兴为您答疑!

您可用下面这个,火狐和IE都可以。
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
$("input:text").keypress(function(event){
if (event.keyCode== 13)$(this).nextAll("input:first").focus();
});
});
</script>
</head>
<body>
<form>
<input type="text" id="input1" />
<input type="text" id="input2" />
<input type="text" id="input3" />
<input type="text" id="input4" />
</form>
</body>
</html>

  您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-05-16
var currKey = e.keyCode || e.which || e.charCode ; 即可
相似回答