Thanks Aaron. That unfortunately didn't make it any faster. Plus I don't
think you'd want to apply that filter expression after you've applied the
":first" qualifier in the initial expression - that could leave you with
nothing even when there's a match somewhere on the page. Anyway, I had the
initial expression reduced all the way down to:

$("#mainContent *:first")

and it wasn't any better, which is why I think I'm stuck having to traverse
the DOM, as much as I'd like to use a jQuery expression. And as I mentioned,
only IE seems to have a problem with it. It works plenty fast in FF. If
anyone else has any suggestions, I'd love to hear them.


On 12/19/06, Aaron Heimlich <[EMAIL PROTECTED]> wrote:

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/



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

Reply via email to