Grow your CSS skills. Land your dream job.

Setting focus to a textarea after it has been loaded via ajax .load()

  • # September 2, 2011 at 7:27 am

    Hi all,

    I’m having trouble trying to set the focus to a textarea that resides inside a div which is ajax loaded using .load().

    I understand that I’ll need to use .live() as this div isn’t in the DOM but I just don’t know how to do it.

    Any help would be great thanks.

    # September 6, 2011 at 8:06 am

    Anyone out there know how to do this? I’m still stuck.

    Cheers

    # September 6, 2011 at 11:51 am

    If #foo is the id of the input element:

    $('#foo').focus();
    # September 7, 2011 at 8:05 am

    Cheers for that but it doesn’t work as the div was loaded after the DOM.

    # September 7, 2011 at 10:01 am

    Hmmm, are you sure?

    http://jsfiddle.net/jamygolden/eUnPX/

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".