# Prevent 'load more' button when all content visible

**URL:** <https://community.hubspot.com/t/prevent-load-more-button-when-all-content-visible/114061>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [August 8, 2024, 11:36am UTC](https://community.hubspot.com/t/prevent-load-more-button-when-all-content-visible/114061 "2024-08-08T11:36:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SiJack](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@SiJack](https://community.hubspot.com/u/SiJack)\
**Post date:** [August 8, 2024, 11:36am UTC](https://community.hubspot.com/t/prevent-load-more-button-when-all-content-visible/114061/1 "2024-08-08T11:36:56Z")

</div>

Hi

We have instances where the filtered list of post content is complete, yet the load more button is still appearing. Can anyone help with the code needed to disable or hide the button when all posts are present?

Here’s an example listing page:

**[Resources | Ardoq | Webinar](https://www.ardoq.com/resources/author/webinar)**

And the current code used for the button:

```lia-code-sample
<script src="{{ get_asset_url('/Website 2020/Assets/JS/libraries/infinite-ajax-scroll.js') }}"></script>
<script>
$(document).ready(function(){
window.ias = new InfiniteAjaxScroll('.related-posts', {
item: '.listing-post',
next: '.next-posts-link',
pagination: '.blog-pagination',
trigger: {
element: function() {
let el = document.createElement('button');
el.innerText = 'Load More';
el.className = "ias-trigger";
document.querySelector('.related-posts').appendChild(el);
return el;
}
}
});
});
</script>

```

Thanks, Si

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 8, 2024, 5:58pm UTC](https://community.hubspot.com/t/prevent-load-more-button-when-all-content-visible/114061/2 "2024-08-08T17:58:35Z")

</div>

Hey, @SiJack 👋 Thanks for your question!

Have you considered adding a check for whether all posts are already visible? By using a function that counts the total number of displayed posts, compares it to the total posts count, and then decides whether to display the ‘load more’ button.

Talk soon! — Jaycee

---

<div class="post-metadata">

**Author:** ![SiJack](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@SiJack](https://community.hubspot.com/u/SiJack)\
**Post date:** [August 12, 2024, 9:40am UTC](https://community.hubspot.com/t/prevent-load-more-button-when-all-content-visible/114061/3 "2024-08-12T09:40:37Z")

</div>

Hi [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) I have not considered that…simply because knowing how to create that function is a bit beyond my obscenely rudimentay capabilities 😄

Would you have any pointers?

Thanks so much!
