[jQuery] Re: how to use focus in a form?
> well my problem is: I have n forms on the website that I working, then > I need one script on jQuery that's work in all using the focus to the > first element onf the form (excluding the firt hidden input), can > someone help me???, my starting code is here: > $(document).ready(function(){ > if('form:first:input'){ > $('input:first').focus(); > }else { > $('select:first').focus(); > } > }); I think this should work. It should put focus on the first visible input of the first form: $(document).ready(function() { $('form:first input:visible:first').focus(); }); This more terse example should do the exact same thing, ignoring the form element and setting focus to the first visible input on the page: $(document).ready(function() { $('input:visible:first').focus(); });
[jQuery] Re: how to use focus in a form?
Instead of doing: $('select:first').focus(); do: $('select:first').get(0).focus(); On Tue, Jan 27, 2009 at 8:40 AM, ƝƟƧǷƕƩŘąŦƱƧ Ɵ MƩƧŦŘƩ wrote: > > well my problem is: I have n forms on the website that I working, then > I need one script on jQuery that's work in all using the focus to the > first element onf the form (excluding the firt hidden input), can > someone help me???, my starting code is here: > $(document).ready(function(){ > if('form:first:input'){ > $('input:first').focus(); > }else { > $('select:first').focus(); > } > }); > -- Benjamin Sterling / Web Developer kenzomedia.com / kenzohosting.com / benjaminsterling.com / refreshbmore.org 443.844.7654 // Twitter @bmsterling Skype: benjamin.sterling // AIM: thekenzoco