jQuery可用时如何处理? [英] How to do something when available with jQuery?

查看:943
本文介绍了jQuery可用时如何处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用JavaScript加载了<textarea>

I've loaded a <textarea> with javascript,

,并且需要尽快关注它.

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

jQuery中的live()必须指定在我的情况下不存在的类型".

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

我需要执行以下操作:

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

如何使用jQuery实现此功能?

How to implement this with jQuery?

推荐答案

使用回调:

$("...").load("/something/to/load.html", function() {
  $("textarea", this).focus();
});

这篇关于jQuery可用时如何处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆