jQuery:如何wrap()动态加载的元素? [英] jQuery: How do I wrap() a dynamically loaded element?
本文介绍了jQuery:如何wrap()动态加载的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为本机没有HTML的第三方应用程序添加皮肤.这一切都来自一个onLoad事件和一堆ajax调用.
I am skinning a 3rd party app that has no HTML natively. It all comes back from an onLoad event and a bunch of ajax calls.
我在页面上添加了jQuery.我需要wrap()一个动态加载的元素.如果需要,我可以包含一个插件.
I added jQuery to the page. I need to wrap() an element that is dynamically loaded. I can include a plugin if needed.
我该怎么做?谢谢.
更新: 这可行,但是有更好的方法吗?
UPDATE: This works, but is there a better way?
$(document).ready(function() {
(function() {
var length = $(".applicationShell").length;
var h = setInterval(function () {
if ($(".applicationShell").length > length) {
length = $(".applicationShell").length;
clearInterval(h);
$(".applicationShell").addClass("test")
}
}, 100);
})();
});
推荐答案
好吧,看来我找不到更好的解决方案. :(这是我用过的那个.
Well, it seems I can't find a better solution. :( Here is the one I used.
$(document).ready(function() {
(function() {
var length = $(".applicationShell").length;
var h = setInterval(function () {
if ($(".applicationShell").length > length) {
length = $(".applicationShell").length;
clearInterval(h);
$(".applicationShell").addClass("test")
}
}, 100);
})();
});
这篇关于jQuery:如何wrap()动态加载的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文