0

My jquery code is like this

$(document).ready(function() {
    $(".slideshow").css("overflow","hidden");
    $("ul#slides").cycle({
    fx: 'fade',
    pause: 1,
    prev: '#prev',
    next: '#next'
});

And i want to know ,is there any slide change event in jquery for this...i mean i need to get the slide number when each slide changes

Thank you

4

1 回答 1

2

Your question is about Cycle specifically, not general jQuery. The documentation on options for Cycle can be found here.

It looks like there is an event called onPrevNextEvent:

onPrevNextEvent: null,// callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)

The second parameter passed into a function you define for that event will be zeroBasedSlideIndex. That's your current slide number, with the first slide starting at 0.

So your code might look something like:

$(document).ready(function() {
    $(".slideshow").css("overflow","hidden");
    $("ul#slides").cycle({
    fx: 'fade',
    pause: 1,
    prev: '#prev',
    next: '#next',
    onPrevNextEvent: function(isNext, slideNum) {
        alert("This is slide "+ slideNum);
    }
});
于 2012-08-28T19:04:44.167 回答