0

I have added to my website this loader

$(window).load(function () {
        $("#page-preloader").fadeOut(300);
});

which as you can see it fades out after everything of the page is loaded.

I would like to have a loader which fades out right after a class is loaded (i.e. class="myclass")) and not wait for everything to get loaded.

Thank you in advance.

Give IT
  • 200
  • 1
  • 3
  • 19

3 Answers3

0

Try:

$('.myclass').load(function () {
        $("#page-preloader").fadeOut(300);
});

Same format as before, just different selector.

JBux
  • 1,394
  • 8
  • 17
0

Try using document ready instead of load to see if the effect is what you need

$(function() {
    $("#page-preloader").fadeOut(300);
});

load() will wait for elements that have url, href and alike attributes.

jperelli
  • 6,988
  • 5
  • 50
  • 85
0
var load_cs = $('.myclass');

if (load_cs.length) {
    $("#page-preloader").delay(3000).fadeOut(300);
}

I did this.. and it is pretty much working as i want. Thanks for the help guys. If anyone has any other advice I will be happy to hear it.

Give IT
  • 200
  • 1
  • 3
  • 19