-2

I'm using the jQuery Cycle plugin and I can find no way to return to the first slide/image via its documentation.

Is there a way to do this programmatically? For example, say you're on slide 4, and there is a DIV with a jQuery.click() event... how would you bind that event to return you to the first slide?

daveycroqet
  • 2,667
  • 7
  • 35
  • 61

2 Answers2

2

You did not look at the demos. Have a look at the Goto demo:

$('#s1').cycle();
$('#goto1').click(function () {
    $('#s1').cycle(0);
    return false;
});

Demo here

I would recommend switching to cycle2 instead. You do not know what you are missing.

Salman A
  • 262,204
  • 82
  • 430
  • 521
  • Thanks, precisely what I was looking for. Not sure why this isn't in the options/API and is referenced only via demo. Next time I'll look harder! And I'll look into cycle2 again but another plugin is dependent on cycle, unfortunately. – daveycroqet Jan 09 '14 at 08:58
1

Simply use the goto command. As per cycle2 documentation, this is how I would do it:

//"DIV with a jQuery.click() event"
<div id="go_to_slide_one" ></div>

// goto 1st slide (slides are zero indexed)
$('#go_to_slide_one').click(function() { 
    $('.cycle-slideshow').cycle('goto', 0);
});
user1678293
  • 85
  • 1
  • 10
  • Just read your comment @daveycroqet. If you cannot use cycle2 this wont work. But i'll leave my answer here in case it is of use to somebody else. – user1678293 Jan 09 '14 at 08:21