Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  150] [ 1]  / answers: 1 / hits: 24190  / 13 Years ago, fri, july 22, 2011, 12:00:00

I have the following code that assigns tabindex to my form id register1. I would like to place the cursor on the first input or select list item on the form (item with tabindex = 1) once tabindexes are assigned. but the following line: $('#register1').find('input').attr('tabindex',1).select();
Resets tabindex of all the inputs.



Full code:



$(function(){
var tabindex = 1;
$('#register1').find('input,select').each(function() {
if (this.type != hidden) {
var $input = $(this);
$input.attr(tabindex, tabindex);
tabindex++;
}
});
$('#register1').find('input').attr('tabindex',1).select();
});


thanks


More From » jquery

 Answers
19

Try :



$('#register1').find('input[tabindex=1]').whatyouwant()

[#91064] Wednesday, July 20, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devonw

Total Points: 311
Total Questions: 116
Total Answers: 111

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;