开发者

How to check if it has class in jQuery?

开发者 https://www.devze.com 2023-04-09 16:38 出处:网络
How can I check if a the #load div has a class also? if (cap > 20) { $(\".p\" + (cap-9)).slideto({ slide_durat开发者_JAVA技巧ion : \'slow\'

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

if (cap > 20) {
$(".p" + (cap-9)).slideto({
    slide_durat开发者_JAVA技巧ion : '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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消