<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" > <ptml> <pead> & Lt;meta http-equiv= "Content-type" content= "text/html; Charset=iso-8859-1 > <title> Press ENTER to jump to next control </title> <script language= "JavaScript" type= text/ JavaScript > var elemtype;//select the control type var elemobj; Select the Control object function Enterkey () {//Get all controls on the page var elems = document.forms[0].elements; var len=elems.length; Set return key jump control type var elemtypeary =["text", "textarea", "Select-one", "button", "Radio", "checkbox"]; var elemtypestr=elemtypeary.join (""); for (Var i=0;i<len;i++) {//Get control type Elemtype=elems[i].type; If the type control in the list is registered for its event if (Elemtypestr.indexof (elemtype)!=-1) {//The control has the focus after it has been assigned the value of the global variable Elems[i].onfocus=function () {// If the current button is typebtn, it is not registered onfocus event if (this.id== "Typebtnid") return; Gets the current control type Elemtype=this.type; Gets the current control object elemobj=this; //If the key is enter, change to tab to jump to the next control elems[i].onkeydown=function () {if (event.keycode==13) event.keycode=9}; }}//ExplicitShows the currently selected control type function GetType () {alert (elemtype); The focus is reset to the previous control Elemobj.focus () by clicking the button and then the button gets the focus; </script> </pead> <body> <form id= "Testform" > <!--registering events for page controls--> <input type= "but Ton "name=" querybtn "value= querybtn" onclick= "Enterkey ()" > <!--Get page control type--> <input type= "button" name= "Ty Pebtn "id=" Typebtnid "value=" typebtn "onclick=" GetType () "> <select id=" sel "> <option value=" 1 ">123< ;/option> <option value= "2" >456</option> </select> <input type= "text" id= "a" > <input typ E= "text" id= "B" > <input type= "text" id= "C" > <textarea rows= "5" cols= "" id= "Taid" ></textarea> <input type= "Radio" name= "Radiongroup" id= "ARd" > <input type= "Radio" name= "Radiongroup" id= "BRD" > < Input type= "checkbox" id= "ACb" > </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]