CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
JavaScript Jungle
Setting focus to a textarea after it has been loaded via ajax .load()
lyleyboy
Permalink to comment
#
September 2011
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.
lyleyboy
Permalink to comment
#
September 2011
Anyone out there know how to do this? I'm still stuck.
Cheers
jamy_za
Permalink to comment
#
September 2011
If #foo is the id of the input element:
$('#foo').focus();
lyleyboy
Permalink to comment
#
September 2011
Cheers for that but it doesn't work as the div was loaded after the DOM.
jamy_za
Permalink to comment
#
September 2011
Hmmm, are you sure?
http://jsfiddle.net/jamygolden/eUnPX/
Add a Comment
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.
Cheers
http://jsfiddle.net/jamygolden/eUnPX/