问题
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?
回答1:
Use a callback:
$("...").load("/something/to/load.html", function() {
$("textarea", this).focus();
});
来源:https://stackoverflow.com/questions/1387464/how-to-do-something-when-available-with-jquery