How to set up a tab sequence in a java script?

Asked By 30 points N/A Posted on -
qa-featured

I'm a little confused about this process or part of using this, so may I ask how do I set up a tab sequence or tab order in a javascript?

SHARE
Best Answer by Sierra Adams
Answered By 0 points N/A #138042

How to set up a tab sequence in a java script?

qa-featured

 

Hi 
 
I am giving you the simple java script for move to tab index.
 
<html>
<head>
<title>
Test Tabs
</title>
<script type="text/javascript">
function check_tab(e) {
if (e.keyCode == 9 ) {
document.getElementById('i1').focus();
e.returnValue = false; // for IE
if (e.preventDefault) e.preventDefault(); // for Mozilla
}
}
</script>
</head>
<body>
<input type="text" id="i1"/>
<br/>
<input type="text" id="i2" onkeydown="check_tab(event)"/>
<br/>
<button type="button">Button</button>
</body>
</html>
 
Best Answer
Best Answer
Answered By 0 points N/A #138041

How to set up a tab sequence in a java script?

qa-featured

 

Hi,

It is very easy. You just need to have the ID’s of elements on which you want to set the tab sequence. Check the following JavaScript code for this purpose. In this code we have set the tab sequence of two elements of html page which are “txtName” and “btnOk”.

  • Document.getElementById("txtName").tabIndex = 1.
  • Document.getElementById("btnOk").tabIndex = 6.

I hope this will helps you. Thank you.

 

Login/Register to Answer

Related Questions