// To Bind the function to the textbox for moving the cursor from one textbox to another
$(document).ready(function () {
$("input:text:first").focus();
$("input:text").bind("keydown", function (e) {
if (e.which == 13) {
e.preventDefault();
var nextIndex = $('input:text').index(this) + 1;
if ($('input:text')[nextIndex] != null)
$('input:text')[nextIndex].focus();
}
});
});
- Here $("input:text:first").focus(); this code helped to focus the first textbox and
- $("input:text").bind("keydown", function (e) {}); is used to bind the ‘Keydown’ event to the each textbox available textbox.
- $('input:text').index(this) is used to get the index of the current text box.
if ($('input:text')[nextIndex] != null)
- This if block is used to check if the next index is having textbox control or not. If the control is available then this will focus into the next textbox.



0 comments:
Post a Comment