Get Current Slide Index of jQuery Cycle 2 Slideshow

May 24th, 2014 - Posted by Steve Marks to Javascript / jQuery, Web Development.

I’ve been using the jQuery Cycle plugin for as long as I can remember, and have even blogged about it in the past. Recently I tried the second version of the plugin, aptly named ‘Cycle 2‘, which worked just as well and is definitely an improvement on the original.

One issue I came across when using the Cycle 2 plugin was that I couldn’t work out how to get the current slide as I wanted to use the current slides index in a callback.

After looking at the documentation it simply reads:

The Cycle2 options hash contains all of the slideshow’s options detailed above, along with the following additional pieces of run-time state

Yet, no where does it give an example of how to access this information. As a result I went digging through the plugin code and managed to figure it out for myself:

$('#product-tour-cycle').data("cycle.opts").currSlide;

So there we have it, how to obtain the current slide index. You can then do with it as you wish.

This entry was posted on Saturday, May 24th, 2014 at 10:28 am by +Steve Marks and is filed under Javascript / jQuery, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.
Comments...

Fear not, we won't publish this

Comments (0)

No comments have been left yet. Be the first