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

$('.myKnownClass').click(function() {

            var interval = setInterval(function(){
                   if($(".menu").length){
                          $('.menu').addClass('testingClass');
                          clearInterval(interval);
                   }
            },200);

 });

其他提示

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.

How can jQuery deferred be used?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top