سؤال

I have a simple jquery-script, embedded into my html code, it uses a plugin written for jquery, called cycle. When I try to use the code, it works, but it keeps looping for some reason. This means that I'm trying to create a simple slideshow, but when I click either "next" or "previous" it does what it should, but after that it continues to scroll the pictures without clicking. Why is this?

<script type="text/javascript">
$('#slide').cycle({
fx: 'scrollHorz',
speed:  'slow',
next:   '#righta',
prev:   '#lefta',
});
</script>
هل كانت مفيدة؟

المحلول

If you are using this plug in then auto scrolling is default behaviour unless you set timeout to 0. Try:

<script type="text/javascript">
$('#slide').cycle({
fx: 'scrollHorz',
speed:  'slow',
next:   '#righta',
prev:   '#lefta',
timeout: 0
});
</script>

نصائح أخرى

This plugin is a slideshow plugin by default which means it will behave as a slide show by default which is what it sounds like the issue is for the op. You need to add the timeout param. Setting it to 0 will stop the slideshow from advancing automatically. so try the below:

   <script type="text/javascript">
     $('#slide').cycle({
       fx: 'scrollHorz',
       speed:  'slow',
       next:   '#righta',
       prev:   '#lefta',
       timeout: 0
     });
   </script>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top