Paul,
So you understand, the array notation Francesco originally brought up is in order to get the DOM element you searched for. A jQuery object is an array DOM elements even if there is only one entry. So, if you wanted to use the browser native function .focus() and not the jQuery helper function .focus(), you want to access the raw DOM element. #("#orderFinder input")[0] is the same as .get(), which does exactly what it says. Now, as to why your original code wasn't working, animations are asynchronous and so the script continues to run after they are started. By using the animations callback function you can see that the next bit of code isn't executed until the animation is completed. HTH -ALEX ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Sent: Friday, March 09, 2007 1:31 PM To: 'jQuery Discussion.' Subject: Re: [jQuery] simple - focusing on an input By the way I solved this by putting the .focus() function in the callback for SlideToggleUp()... ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andy Matthews Sent: Friday, March 09, 2007 1:29 PM To: 'jQuery Discussion.' Subject: Re: [jQuery] simple - focusing on an input It references the first matching element. It's array notation. ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Sent: Friday, March 09, 2007 2:24 PM To: 'jQuery Discussion.' Subject: Re: [jQuery] simple - focusing on an input Thanks for the reply, Francesco. Your suggestion didn't seem to work-but what is the purpose of the [0] there? ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Francesco Sullo Sent: Friday, March 09, 2007 12:25 PM To: jQuery Discussion. Subject: Re: [jQuery] simple - focusing on an input Use: $("#orderFinder input").val('')[0].focus() --Francesco Paul ha scritto: I'm trying to focus the cursor in a text box at the end of a simple animation, and it won't. The cursor shows up temporarily in the box, then flits away... $("#orderFinder").SlideToggleUp(250, null, 'bounceout'); // show/hide the div $("#orderFinder input").val('').focus(); // reset the value and focus on the field ________________________________ _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/