多个Jquery幻灯片。

我正在尝试使用jquery cycle all创建一个包含多个jquery幻灯片放映的页面,每个幻灯片都有自己的下一个,上一个按钮。这是我的代码:
<script type=\"text/javascript\">

$(document).ready(function(){ 
    $(\'#slideshow\').cycle({
    fx:\'fade\', 
    speed:1, 
    timeout: 0, 
    next:\'#next\',
    prev:\'#prev\',
    });
});

    </script>
和HTML 2幻灯片(但我想要4)
<div id=\"content\">
<a name=\"1\" id=\"1\"></a>
<div id =\"slideshow\">
  <img src=\"image2.jpg\" width=\"675\" height=\"420\" />
  <img src=\"image.jpg\" width=\"675\" height=\"420\" />
</div>
<a id=\"prev\" href=\"#\" class=\"Code-Pro3\">Prev</a> &nbsp;&nbsp;  <a id=\"next\" href=\"#\" class=\"Code-Pro3\">Next </a>


<a name=\"2\" id=\"2\"></a>
<div id =\"slideshow2\">
  <img src=\"image.jpg\" width=\"675\" height=\"420\" />
  <img src=\"image2.jpg\" width=\"675\" height=\"420\" />
</div>
<a id=\"prev\" href=\"#\" class=\"Code-Pro3\">Prev</a> &nbsp;&nbsp;  <a id=\"next\" href=\"#\" class=\"Code-Pro3\">Next </a>
任何帮助表示赞赏。谢谢。     
已邀请:
为了使两个单独的div具有自己的上一个和下一个链接,您需要调用两次循环,并为链接使用唯一的ID。因此您的脚本应如下所示:
<script type=\"text/javascript\">

$(document).ready(function(){ 
    $(\'#slideshow1\').cycle({
    fx:\'fade\', 
    speed:1, 
    timeout: 0, 
    next:\'#next1\',
    prev:\'#prev1\',
    });
$(\'#slideshow2\').cycle({
    fx:\'fade\', 
    speed:1, 
    timeout: 0, 
    next:\'#next2\',
    prev:\'#prev2\',
    });
});

</script>
和您的标记看起来像:
<div id=\"content\">
<a name=\"1\" id=\"1\"></a>
<div id =\"slideshow1\">
  <img src=\"image2.jpg\" width=\"675\" height=\"420\" />
  <img src=\"image.jpg\" width=\"675\" height=\"420\" />
</div>
<a id=\"prev1\" href=\"#\" class=\"Code-Pro3\">Prev</a> &nbsp;&nbsp;  <a id=\"next1\" href=\"#\" class=\"Code-Pro3\">Next </a>

<a name=\"2\" id=\"2\"></a>
<div id =\"slideshow2\">
  <img src=\"image.jpg\" width=\"675\" height=\"420\" />
  <img src=\"image2.jpg\" width=\"675\" height=\"420\" />
</div>
<a id=\"prev2\" href=\"#\" class=\"Code-Pro3\">Prev</a> &nbsp;&nbsp;  <a id=\"next2\" href=\"#\" class=\"Code-Pro3\">Next </a>
有关示例,请参见http://www.malsup.com/jquery/cycle/scrollhv.html。 希望能有所帮助, 大卫     
告诉页面上的每个“ 4”查找自己的上一个和下一个按钮的一种方法是将幻灯片放映以及上一个和下一个按钮分组到同一父对象中,然后使用jQuery选择器进行查找:
<script type=\"text/javascript\">
  $(document).ready(function() {
    $(\'.slideshow\').each(function(){
      $(this).cycle({
        fx:\'fade\', 
        speed:1, 
        timeout: 0,
        next: $(\'.next\', $(this).parent()),
        prev: $(\'.prev\', $(this).parent())
      });
    });
  });
</script>
现在,在html中,您可以使用类而不是ID,只是不要忘记将每个幻灯片按其自身的上一个和下一个按钮进行分组。
<div id=\"content\">
  <div>
    <a name=\"1\" id=\"1\"></a>
    <div class =\"slideshow\">
      <img src=\"image2.jpg\" width=\"675\" height=\"420\" />
      <img src=\"image.jpg\" width=\"675\" height=\"420\" />
    </div>
    <a href=\"#\" class=\"Code-Pro3 prev\">Prev</a> &nbsp;&nbsp;  <a href=\"#\" class=\"Code-Pro3 next\">Next </a>
  </div>

  <div>
    <a name=\"2\" id=\"2\"></a>
    <div class =\"slideshow\">
      <img src=\"image.jpg\" width=\"675\" height=\"420\" />
      <img src=\"image2.jpg\" width=\"675\" height=\"420\" />
    </div>
    <a href=\"#\" class=\"Code-Pro3 prev\">Prev</a> &nbsp;&nbsp;  <a href=\"#\" class=\"Code-Pro3 next\">Next </a>
  </div>
  ...
    

要回复问题请先登录注册