Home > Mobile >  jQuery: hide show more button when no content to load
jQuery: hide show more button when no content to load

Time:01-28

I have this button that will hide when no more content to load in review page. The button is working great except that it will still show up even if there are no more data to display. I want it to not show up if there is nothing left to load. Does anyone have any suggestions? Thank you.

Here is my code

  $(document).unbind('click').on('click', ".recentreviews5 .showmore", function () {  
    $('#last').val(parseInt($('#last').val())   10)

    $('.hide').each(function () {
        var itmidx = $(this).index();
        if (parseInt(itmidx) < parseInt($('#last').val())) {
                        
            var g = $(this).attr('id')

            $(this).removeClass('recent').removeClass('hide')
            $(this).addClass('recent').addClass('show')
        }
    });

    if ((parseInt($('#last').val()) >= parseInt($('#total').val())) || (parseInt($('#last').val()) < 10)) {
        $(".showmore").css('cssText', 'display:none!important')
    }
   
});

CodePudding user response:

You can use this code to manually set the style. The .css call generally speaking doesn't support !important.

$(".showmore").attr('style', 'display: none !important')

CodePudding user response:

$(".showmore").attr('hidden', 'hidden')

CodePudding user response:

$(".showmore").toggle();
  •  Tags:  
  • Related