Home › Forums › JavaScript › AnythingSlider – Appending Forward and Back Buttons (half working) › Re: AnythingSlider – Appending Forward and Back Buttons (half working)
Hiya!
Yeah I’m a gud speeler. I fixed that in the newer playground versions, so I thought it wasn’t going to haunt me! LOL oh well.
You can use the AnythingSlider api to advance the slides forward and back like this ([here’s a demo](http://jsfiddle.net/Mottie/XkHvg/1/))
var api = $(‘#slider’).data(‘AnythingSlider’);
$(‘.go-forward, .go-back’).click(function(){
if ($(this).hasClass(‘go-forward’)) {
api.goForward();
} else {
api.goBack();
}
return false;
});
Here is a more condensed version that is harder to read but does exactly the same thing:
var api = $(‘#slider’).data(‘AnythingSlider’);
$(‘.go-forward, .go-back’).click(function(){
api[$(this).hasClass(‘go-forward’) ? ‘goForward’ : ‘goBack’]();
return false;
});