Try this (completely untested):

$("#mainContent :input:enabled:visible:first")
    .filter(["textarea","select","[EMAIL PROTECTED]'text']"])
       .each(function() {
           this.focus();
        });

On 12/19/06, Todd Menier <[EMAIL PROTECTED] > wrote:

Hello,
I'm writing a function in a global script that will apply focus to the
first visible enabled form field on a page. I'm using the following jQuery
expression to find the control:

$('#mainContent
:input:visible:not(:checkbox):not(:button):not(:submit):not(:image):not([EMAIL 
PROTECTED]):first')


This works exactly as expected, but unfortunately it's quite slow in IE 7
when there is a fairly large amount of HTML (about 12 seconds on a page that
contains 2 select lists with several hundred options each). I had assumed
that the ":first" qualifier would cause the search operation to stop after
it finds a match, but that doesn't seem to be the case. And the problem
doesn't seem to be with any of the other specific qualifiers I'm using;
"*:first" is equally slow.

I think I need to do this the long way, traversing the DOM and checking
all the conditions manually, just so I can stop when a match is found.
Unless anyone can think of a way I can accomplish this and still take
advantage of jQuery's coolness in some way?

Thanks in advance,
Todd


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to