- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › AnythingSlider: parameter on function to call plugin
Uhm, I’m sorry but it’s still not clear what that number does!
https://github.com/CSS-Tricks/AnythingSlider/issues/518
From what I understand it should “set the current slide”, but what does that mean? If I change the number nothing changes…
The code you are seeing:
var changeToSlide = 6;
jQuery(‘.anythingSlider’).anythingSlider(changeToSlide);
is how to change the slide AFTER Anything has initialized. So, if you add a button (or link, or whatever) to your page and add this code:
jQuery(function($){
// initialize the slider
$(‘#slider’).anythingSlider();
// click the button to change to slide 3
$(‘button’).click(function(){
$(‘#slider’).anythingSlider(3);
});
});
Run [this demo](http://jsfiddle.net/Mottie/ycUB6/5309/), click on the button and you’ll see the slider change to the third slide (there are only 5 slides).
If you want to start the slider on the third slide, then set the [`startPanel` option](https://github.com/CSS-Tricks/AnythingSlider/wiki/Navigation-options#startpanel-1) to whatever number slide you want to start on:
jQuery(function($){
// initialize the slider, and start on the third panel
$(‘#slider’).anythingSlider({
startPanel: 3
});
});
Oh! Thanks!! Clear now! :-)