Home > Web Front-end > JS Tutorial > body text

A small example of converting Enter to Tab (compatible with IE, Firefox)_javascript skills

WBOY
Release: 2016-05-16 17:15:13
Original
984 people have browsed it
复制代码 代码如下:

document.onkeydown=function(e){
  var e=window.event||e;
  var element=e.srcElement||e.target;
  if(e.keyCode==13&&element.type!="submit"&&element.type!="button"&&element.type!="textarea"&&element.type!="reset"){
    if(document.all){
      e.keyCode=9;
    }else{
      getNextInput(element).focus();
      e.preventDefault();
    }
  }
}
function getNextInput(input){
  var form=input.form;
  for(var i=0;i    if(form.elements[i]==input){
      break;
    }
  }
  while(true){
    if(i       if(form.elements[i].type!="hidden"){
        return form.elements[i];
      }
    }else{
      return null;
    }
  }
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template