# CMS Slider - Displaying when empty

**URL:** <https://forum.finsweet.com/t/cms-slider-displaying-when-empty/2328>\
**Category:** General\
**Created:** [January 4, 2024, 11:53am UTC](https://forum.finsweet.com/t/cms-slider-displaying-when-empty/2328 "2024-01-04T11:53:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashley](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/ashley/32/3842_2.png) [@ashley](https://forum.finsweet.com/u/ashley)\
**Post date:** [January 4, 2024, 11:53am UTC](https://forum.finsweet.com/t/cms-slider-displaying-when-empty/2328/1 "2024-01-04T11:53:53Z")

</div>

We are using the CMS slider on our search results page. Previously, if there were no search results, the slider didn’t display. But recently, it seems that there’s a bug with the slider script and it’s not hiding when empty. @Support-Luis is there anything I can do to hide the slider when there are no results? Thanks for your help!

> **[Search with Applerouth for Educational Resources](https://applerouth.webflow.io/search)**
>
> Explore Applerouth's search functionality. Find educational resources, articles, and guidance for academic success easily.

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [January 4, 2024, 1:20pm UTC](https://forum.finsweet.com/t/cms-slider-displaying-when-empty/2328/2 "2024-01-04T13:20:08Z")

</div>

hey @ashley! You can check if the empty element is present on the page and if it is you can hide the slider.

This snippet should do the trick

```js
<script>
  window.onload = () => {
    const emptyElement = document.querySelector('[fs-cms-element = "empty"]');
    const sliderElement = document.querySelector('[fs-cmsslider-element="slider"]');
    emptyElement ? (sliderElement.style.display = 'none') : console.log('items found');
  };
</script>

```

---

<div class="post-metadata">

**Author:** ![ashley](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/ashley/32/3842_2.png) [@ashley](https://forum.finsweet.com/u/ashley)\
**Post date:** [January 5, 2024, 4:53am UTC](https://forum.finsweet.com/t/cms-slider-displaying-when-empty/2328/3 "2024-01-05T04:53:53Z")

</div>

Fab, this is now resolved - thanks @Support-Luis

---

<div class="post-metadata">

**Author:** ![ashley](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/ashley/32/3842_2.png) [@ashley](https://forum.finsweet.com/u/ashley)\
**Post date:** [January 5, 2024, 4:54am UTC](https://forum.finsweet.com/t/cms-slider-displaying-when-empty/2328/4 "2024-01-05T04:54:05Z")

</div>


