Here's the Link to the Fiddle.
I'm working with a carousel and I want to make the next/previous buttons functional.
I tried adding the following code but it doesn't update the index properly. Any help would be appreciated!
$($btnNext).click(function (event) {
updateSlides(index + 1);
event.preventDefault();
}
$($btnPrev).click(function (event) {
updateSlides(index - 1);
event.preventDefault();
}
When the
clickevent on those buttons is called, thatindexvariable is undefined. There are several different ways of figuring out the index, the method I used in the fiddle was to set anattributeon thesliderand then check it on theclickevents:See the updated fiddle here: http://jsfiddle.net/sbp76sLc/14/