EnexoOnoma
EnexoOnoma

Reputation: 8836

How to check if it has class in jQuery?

How can I check if a the #load div has a class also?

if (cap > 20) {
$(".p" + (cap-9)).slideto({
    slide_duration : 'slow'
});
}

Upvotes: 1

Views: 232

Answers (1)

tmsimont
tmsimont

Reputation: 2711

you could try just adding a class to the button once it's been clicked:

$("#loadmore").click(function() {
    cap += 10;
    $(this).addClass("loadmore-clicked");
$(".p" + (cap-10)).addClass("loading");
setTimeout(function() {
    $(".p" + (cap-10)).removeClass('loading');
}, 7000);
    loadfeed();

});

And then just see if you have that class on the button below:

function loadfeed(){    
    if ($("#loadmore").hasClass("loadmore-clicked")){
      //loadmore was clicked
    }else{
      //loadmore hasn't been clicked
    }
}

Upvotes: 1

Related Questions