O'Reilly logo

jQuery for Designers Beginner's Guide by Natalie MacLees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — adding pagination controls

Next, we want to set up the function that will create the next button, previous button, and pagination buttons and makes them work.

  1. The jCarousel plugin provides a key called initCallback that will allow us to pass in the name of a function that should be called when the carousel is created. Let's get started by creating an empty function and calling it:
    var slider = $('#featured-carousel');
    function carouselInit(carousel) {
    // Our function goes here
    }
    $(document).ready(function(){
    slider.jcarousel({
    scroll: 1,
    buttonNextHTML: null,
    buttonPrevHTML: null,
    initCallback: carouselInit	
    });
    });
    

    Whatever actions we write inside of our carouselInit() function, it will be executed when the carousel is initialized ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required