Unable to implement a random slide upon refresh using code

https://discourse.webflow.com/t/change-background-image-on-refresh/1120/12

Please refer to the above thread.
I used the code as told by @Waldo in the head section of my website and published it, but it doesn’t seem to work.
I want to obtain a random hero image each time the website refreshes, so I have used a slider, set to full screen then - disabled autoplay and added the set of images.

Then I implemented this code as told by Waldo in the settings, but I still cant get it to work. Please help.

<script>
  $(".mask").append($(".mask").children().sort(function () {
    return Math.random() - 0.5;
}));
</script>

Hi @tanyasingh thank you very much for reaching out. You would have to give your slide “Mask” element the class name of mask for that to work.

Could you please update your post with some more information so we can help you faster? Things like your read-only link & screenshots really helps us to help you faster :slight_smile:

How to share a read-only link:

Thanks in advance! :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.