$(function() { $('.slide').unslider({ speed: 500, // The speed to animate each slide (in milliseconds) keys: true, // Enable keyboard (left, right) arrow shortcuts }); }); var activeDot = 0; var unslider = $('.slide').unslider(); $('.unslider-arrow').click(function() { var fn = this.className.split(' ')[1]; // Either do unslider.data('unslider').next() or .prev() depending on the className if(fn = 'next'){ activeDot++; }else{ activeDot--; } if(activeDot > 0-1){ activeDot = 0; } console.log(activeDot); $('.dota').addClass('dot').removeClass('dota'); $('#dot'+activeDot).addClass('dota').removeClass('dot'); unslider.data('unslider')[fn](); }); function dotPressed(moveTo){ unslider.data('unslider').move(moveTo); $('.dota').addClass('dot').removeClass('dota'); $('#dot'+moveTo).addClass('dota').removeClass('dot'); }