Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript AnythingSlider – Appending Forward and Back Buttons (half working) Re: AnythingSlider – Appending Forward and Back Buttons (half working)

#115290
Mottie
Member

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