3gwebtrain
3gwebtrain

Reputation: 15297

How to find the div is loaded or not?

i am using a plug-in to load the facebook in to my page. i need to adjust some padding within the loaded content. i can't use the css to do this, because the ajax loading that content finally.

so, i decided to do this using jquery, so i written a interval function to find that div with class loaded or not, once it loaded i need to apply my style. for this i wrote this function

$(window).bind('load',function(){
    var faceBook = $('div').hasClass('connect_top');
    var faceInterval = setInterval(function(){
        if(faceBook.complete){
            faceBook.css({border:'1px solid red'});
            clearInterval(faceInterval);
        }
    },50)
});

but no luck, any one can help me to achieve this?

Thanks in advance!

Upvotes: 0

Views: 640

Answers (2)

Jason Gennaro
Jason Gennaro

Reputation: 34853

You could use .ajaxComplete()

So something like

$('.connect_top').ajaxComplete(function(){
    $(this).css({border:'1px solid red'});
});

http://api.jquery.com/ajaxComplete/

Upvotes: 2

FishBasketGordo
FishBasketGordo

Reputation: 23142

You can modify the div in the success handler of the AJAX call. If you're using jQuery to make the call it would look something like this:

$.ajax({

    // Other AJAX settings...

    success: function(data, textStatus, jqXHR) {
        $('div.connect_top').css({border:'1px solid red'});
    }
});

Upvotes: 1

Related Questions