If anyone cares, here's what I finally resorted to. Thought maybe I could at
least use $(form.elements) and still apply my filter, but IE doesn't treat
form.elements as an array, nor does it appear to treat the individual
elements as true DOM nodes. So as much as it pained me to do it, here's the
(very un-jQuery) solution I came up with:

var fields = document.forms[0].elements;
for (var i = 0; i < fields.length; i++) {
   var tag = fields[i].tagName.toLowerCase();
   if ((tag == 'textarea' || tag == 'select' || (tag == 'input' &&
fields[i].type == 'text'))
       && fields[i].style.visibility != 'hidden'
       && fields[i].style.display != 'none'
       && !fields[i].disabled)
   {
       fields[i].focus();
       break;
   }
}

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

Thank you for all the suggestions. Yes, we are most definitely looking at
ways to rein in the big select lists, but that won't happen overnight,
unfortunately. I would argue that hundreds of nodes is fairly big, but not
big enough to explain it taking 12+ seconds to process, especially when the
same operation takes a fraction of a second in FF. I would venture to guess
that it has more to do with IE not liking the algorithm used for some
reason.

I did try doing something involving this:

$('textarea,select,[EMAIL PROTECTED]')

and that completely eliminated the performance problem, but it returns the
elements in the order you specified (all textareas, then all selects, then
all inputs) rather than in the order that they appear in the document. I
couldn't come up with a way to compare 2 nodes and determine which comes
first in the document. Comparing their top/left positions is a possibility.

But I think I'm going to do this by looping through form.elements. It's
easy, fast, and appears to have adequate browser support. And even if it
doesn't work in all browsers, I don't consider this "mission-critical"
functionality anyway.

Thanks again for the suggestions.

Todd



On 12/20/06, Dave Methvin <[EMAIL PROTECTED] > wrote:
>
> > Did you perhaps mean filter() instead of select()?
>
> Yep, I meant filter(), thanks for the catch.
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


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

Reply via email to