Streaming live at 10am (PST)

Custom code to set the default starting slide to slide 2


#1

Hi all,

I have made a custom slider that shows the previous and next slides ghosted out, I would like to set the default starting slide to slide 2, that way the left previous slide is visible.

Does anyone out there have any custom code to override the defaults?

I cannot share the read only link, it is confidential, the question basically applies to any Webflow slider.

I have attached images of the default starting position and the preferred position.

Default:

Preferred:

Thanks Graham

Here is my site Read-Only: LINK
(how to share your site Read-Only link)


#2

Hello @allthingsGJD

Can you try using the script bellow

<script>
$(document).ready(function() {
    $('#sliderId div:nth-child(slideNumber)').trigger('tap');
}); 
</script>

Paste the code before the closing body tag

Hope this helps

Piter :webflow_heart:


#3

Hi Piter,
Thanks for taking the time to jump in.

I am a none coder, as such I understand the process of adding the code to the body tag, however I do not understand the use of the script.

Do I need to apply an iD to the slider?
Do I need to identify slide 2?

If you could expand on how to use it, that would be great.

Thanks Graham


#4

No problem!

Click on the slider element and add an ID > for example #myslide > add the script to the closing body tag > change the #sliderId with the ID of your slider > specify the slide number you want to be active on load.

See screen record > https://www.useloom.com/share/531c51fe1f7f4ec79675a13731ebde79

Piter :webflow_heart:


#5

Thanks Piter, sorry I still do not understand which part I change (or add) to specify the slide number, do it replace the (slideNumber) part or do I add the number somewhere else?

Thanks Graham