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 ...

Get jQuery for Designers Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.