How to do something when available with jQuery?

限于喜欢 提交于 2019-12-11 15:43:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!