JS Operation Press ENTER focus to move to the next control

Source: Internet
Author: User

  Just as the title says use JS to press ENTER focus to move to the next control, the specific implementation example below, need friends can refer to the following

The code is as follows: <html>  <head>  <title>Enter2Tab</title>  <script type= "text/ JavaScript ">  window.onload=function () {  var list = new Array ();  for (Var i=5;i< document.all.length;i++)   {  if (document.all[i].type== "Text" | | document.all[i].tagname== "SELECT")   List.push (i); }    for (var i=0;i<list.length-1;i++)   {  Document.all[list[i]].setattribute ("Nextfocusindex", list[i+1));  Document.all[list[i]. onkeydown=jumptonext; }  for (var i=list.length-1;i<document.all.length;i++)   {  if ( document.all[i].type== "button")   {  document.all[list[list.length-1]].setattribute ("NextFocusIndex", i) ;  document.all[list[list.length-1]].onkeydown=jumptonext;  break; } }  document.all[ List[0]].focus (); }  function Jumptonext () {  if (event.keycode==13)   {  var nextfocusindex= This.getattribute ("Nextfocusindex");  document.All[nextfocusindex].focus (); } }  </script>  </head>  <body>  < Input id= "A" name= "a" type= "text"/>  <input id= "B" name= "B" type= "text"/>  <input id= "C" Name= "C" Type= "text"/>  <input id= "D" name= "D" type= "text"/>  <input "E" id= "E" name= "text" type= P <select id= "S1" name= "S1" >  <option>1</option>  <option>2</option>  <option>3</option>  <option>4</option>  <option>5</option>  </select>  <select id= "S2" name= "S2" >  <option>1</option>  <option>2 </option>  <option>3</option>  <option>4</option>     
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.