How to start with a specific index - basic jquery slider

流过昼夜 提交于 2020-01-17 04:02:46

问题


I am using a slider Basic Jquery Slider

I want to start with 2nd index or sometimes 3rd index.

How can I achieve this? I tried options below, but did not work:

$('#banner-slides').bjqs({
   animtype     : 'slide',
   currentslide : 2,
   currentindex : 1
});

回答1:


    this.goto = function(position){ // this keyword is added here
        state.animating = false;
        if(settings.animtype === "slide")
            position = position + 1;
        go(false,position);
    }
    init();
    return this; // newly added code

You can add the above script to the bjqs-1.3.js file and initialize the slider like

var bannerslides = $('#banner-slides').bjqs({
   animtype     : 'slide'
});

then use bannerslides.goto(1) to go to first slide

you can create multiple sliders like

var bannerslides1 = $('#banner-slides1').bjqs({
   animtype     : 'slide'
});


var bannerslides2 = $('#banner-slides2').bjqs({
   animtype     : 'slide'
});

and use it like bannerslides1.goto(1) to go to first slide of bannerslides1 slider and bannerslides2.goto(1) to go to first slide of bannerslides2 slider

I hope you can calculate the slidenumbers

NOTE : I haven't tested fully.

UPDATE

I have added one more condition to make it work if the animation was fade

UPDATE

Find the new code and let me know if it works



来源:https://stackoverflow.com/questions/26403703/how-to-start-with-a-specific-index-basic-jquery-slider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!