views:

49

answers:

1

I've loaded a <textarea> with javascript,

and need to focus on it as soon as it's available.

The live() in jQuery must specify a "type" which doesn't exists in my case.

I need to do something like below:

$('#target').onAvailable($('#target').focus());

How to implement this with jQuery?

+2  A: 

Use a callback:

$("...").load("/something/to/load.html", function() {
  $("textarea", this).focus();
});
cletus
In fact I'm doing something like :$('#loader').clone().removeAttr('id').load("Views/chatBox.html").appendTo('body');
Shore
you can still add a callback there
Daniel