Image change on page refresh

$(document).ready(function() {
var images = [ ‘image1.png’, ‘image2.png’, image3.png’ ];
var random = 1 + Math.floor(Math.random() * images.length);

$(‘.slider-class’).html(‘’);
});

Can someone better clarify how to go about doing this. I see the code above, but am not sure where I would place my images. Also it looks like it’s using a slider class and I don’t want this to be a slider but to simply change out an image on refresh.


Hi @melphiz6, where those image names are image1.png, image2.png etc, you would change those names and put in the path to where your images are stored. If you click on an image in the Asset Manager, you can click on the gear icon and copy the path to the image in Webflow. You would paste that path into the script you have above.

It would really help if you could share the read only link to your site, and then it will help to get this working faster :slight_smile: Share a read-only link | Webflow University

I hope this helps…

@cyberdave awesome thanks. I’ll give this a try. I’m assuming I need to put the images in a slider? Will this code then affect all other sliders on my website?

If it’s helpful here is my link. I just don’t have much up yet.
https://preview.webflow.com/preview/feinberghanson?preview=a2da3ca34b20844ac3644eec3959a681

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