简体   繁体   中英

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'
});
}

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
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM