function enterToTab(event){  
  var e = event ? event : window.event  
  if(e.keyCode == 13){  
     e.keyCode = 9;  
  }  
}
<form> 
<input type="text" >
</form> 

注意:FireFox 的e.which 属性是只读的,不能更改,所以上面的方面只能用于IE浏览器。
事件,也只能用onkeydown 事件,而不要用onkeypress 事件,因为对于onkeypress 事件,
event.keyCode(IE) 和 e.which(Firefox) 是读取不到回车键(13)的,所以要使用onkeydown 事件

下面是jquery 方案,兼容IE 与firefox
$(document).ready(function(){
    // get only (input:text) tags with class data-entry
    textboxes = $("input:text");
    // now we check to see which browser is being used
    if ($.browser.mozilla) {
        $(textboxes).keypress (checkForEnter);
    } else {
        $(textboxes).keydown (checkForEnter);
    }
});
function checkForEnter (event) {
    if (event.keyCode == 13) {
          currentBoxNumber = textboxes.index(this);
        if (textboxes[currentBoxNumber + 1] != null) {
            nextBox = textboxes[currentBoxNumber + 1]
            nextBox.focus();
            nextBox.select();
            event.preventDefault();
            return false;
        }
    }
}

相关文章:

  • 2021-10-04
  • 2021-06-22
  • 2022-01-19
  • 2021-07-23
  • 2021-12-17
  • 2021-09-15
  • 2022-12-23
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案