I'm using jCarousel Lite and need to get the current index (which element is being displayed as I'm only showing one item at a time) so I can add a "current" class to the navigation link.
Does anybody know how I can accomplish this?
I'm using jCarousel Lite and need to get the current index (which element is being displayed as I'm only showing one item at a time) so I can add a "current" class to the navigation link.
Does anybody know how I can accomplish this?
First download the uncompressed version of jCarousel Lite and open it. Go to line 288*, or anywhere below the o.beforeStart.call(), and add the following:
Next go to line 313*, anywhere below the ul.animate();, or even within the animate() callback and add the following:
That's it for the jCarousel Lite modifications. Save the file / upload the changes.
Finally you'll want to set the current class once the page loads. For that use:
*Note to future readers: This change is for v1.0.1. The actual line number may vary.
From the documentation at the link you posted:
So, create a function that sets your "current" class, and pass it as the
afterEnd
option when you create the carousel.