$('.myKnownClass').click(function() {
var interval = setInterval(function(){
if($(".menu").length){
$('.menu').addClass('testingClass');
clearInterval(interval);
}
},200);
});
Get class of dynamically created div - jQuery
题
Alright I have this :
$('.myKnownClass').click(function() {
$('.menu').addClass('testingClass');
});
When I click on the .myKnownClass, another script adds a div.menu, but it doesn't create it instantly (like 0.4 seconds, depends on the server).
Is there any way, within the "click", to wait till a div.menu is present on the body ?
Thanks.
解决方案 2
其他提示
Maybe you could do something with jQuerys Deferreds. I don't really know how to use it, but maybe you can do something with it.
不隶属于 StackOverflow