On second thought, you'll want to use .find, instead of .children, as the
elements could likely be within fieldsets and/or divs:

$('form:has(#elHombre)').find('input, select, textarea')[0].focus();

Also, here's another way to get the form from the #elHombre:

$('#elHombre').parents('form:first').find('input, select,
textarea')[0].focus();

- Richard

On Mon, Mar 31, 2008 at 6:26 AM, Richard D. Worth <[EMAIL PROTECTED]> wrote:

> $('form:has(#elHombre)').children('input, select, textarea')[0].focus();
>
> - Richard
>
>
> On Mon, Mar 31, 2008 at 6:12 AM, dug <[EMAIL PROTECTED]> wrote:
>
> >
> > Thanks Jason :-)
> >
> > How would I handle that if the #elHombre object is inside the form?
> >
> > Cheers,
> > Dug
> >
> >
> > On Mar 27, 12:21 pm, Jason Huck <[EMAIL PROTECTED]> wrote:
> > > Try this:
> > >
> > > $('#elHombre').next('form').children('input select textarea')
> > > [0].focus();
> > >
> > > - jason
> > >
> > > On Mar 27, 6:32 am, "DugFalby" <[EMAIL PROTECTED]> wrote:
> > >
> > > > Hi guys,
> > >
> > > > I've got:
> > >
> > > > $('#elHombre').focus();
> > >
> > > > Which sets focus to a legend at the top of a form.
> > >
> > > > I'd like to do:
> > >
> > > > $('#elHombre').next-instance-of-tag-of-type==
> > inputORtextareaORselect.focus();
> > >
> > > > The page is set to scroll to the elHombre anchor. The focus needs to
> > > > be set to thefirstform control that follows the anchor. For example:
> > >
> > > > <p id="elHombre">
> > > > This is the introduction</p>
> > > > <form>
> > > >     <label>
> > > >     Your name:
> > > >     <input type="text" /></label>
> > > > </form>
> > >
> > > > The script would set the focus to the text input box.
> > >
> > > > Thanks all :-)
> > >
> > > > Best,
> > > > Dug
> > >
> > > > --
> > > > DugFalby
> > > > +44 75 15 66 16 55http://www.donkeyontheedge.com/
> >
>
>

Reply via email to