Grow your CSS skills. Land your dream job.

AnythingSlider: parameter on function to call plugin

  • # April 10, 2013 at 8:54 am

    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…

    # April 10, 2013 at 12:56 pm

    cc @Mottie ;)

    # April 10, 2013 at 1:06 pm

    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
    });

    });

    # April 10, 2013 at 7:23 pm

    Oh! Thanks!! Clear now! :-)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".