【问题标题】:Multiple Image slider on one page using JQuery使用 JQuery 一页上的多个图像滑块
【发布时间】:2014-04-07 06:14:11
【问题描述】:

我已经看到了几个相关的问题,但我仍在努力理解它们。所以在测试它时,我想发布这个问题,希望有人可以看到它并给予一些启发。

我的目标是使用相同的(一个)jquery 脚本为不同类别的图像滑块使用 Drupal 中的不同块,这些块将全部显示在主页上。因此,

Block1 - 包含类别 1 的图像滑块 Block2 - 包含类别 2 的图像滑块 Block3 - 包含类别 3 的图像滑块

等等..

我已经能够创建不同的块,但是每次我尝试单击下一个箭头时页面才会刷新。

我从http://coolcarousels.frebsite.nl/ 得到的 JS 如下:

     <script type="text/javascript">
        $(function() {

            $('#carousel ul').carouFredSel({
                prev: '#prev',
                next: '#next',
                pagination: "#pager",
                scroll: 500,
                auto: false
            });

        });
    </script>
           <script src="jquery.carouFredSel-6.0.4-packed.js" type="text/javascript"></script>

HTML 是:

    <div id="wrapper">
        <div id="carousel">
            <ul>
            <li><a href=""><img src="" width="100px"/></a><span>Image1</span></li>
            <li><a href=""><img src="" width="100px"/></a><span>Image2</span></li>
            <li><a href=""><img src="" width="100px"/></a><span>Image3</span></li>
            <li><a href=""><img src="" width="100px"/></a><span>Image4</span></li>
            <li><a href=""><img src="" width="100px"/></a><span>Image5</span></li>
            <li><a href=""><img src="" width="100px"/></a><span>Image6</span></li>

            </ul>
            <div class="clearfix"></div>

            <a id="next" class="next" href="#">&gt;</a>

        </div>
    </div>

提前谢谢大家。

【问题讨论】:

  • 你有caroufredsel插件吗..是那个插件的脚本...
  • @Jaimin MosLake。我更新了上面的问题。我注意到我没有包含这个问题。
  • 如果我理解正确.. 您需要三个不同位置的三个滑块...假设一个在页眉,第二个在正文,第三个在页脚...意味着它将位于三个不同的 div还是uls……?我理解正确...?滑块在 thress 不同的 div 或 uls ...?
  • 你需要三个不同的 div 或 uls id 和...三个脚本每个...和 ​​3*2=6 下一个上一个按钮
  • 是的,你是对的。我已经为每个类别使用了不同的 ID,例如#carousel1、#carousel2。它们也在不同的 div 中。事实上,我正在使用该脚本和 HTML(其中图像仅针对每个类别/块更改)

标签: jquery carousel caroufredsel


【解决方案1】:
<script type="text/javascript">
$(document).ready(function() {
// Using default configuration
$('#moreVideos_carousel').carouFredSel();

// Using custom configuration
$('#moreVideos_carousel').carouFredSel({
    circular: true,    
    items               : 3,
    direction           : "left",
    scroll : {
        items           : 3,
        easing          : "elastic",
        duration        : 1000,                         
        pauseOnHover    : true
    },     
    prev    : {
    button  : "#morevideos_prev",
    key     : "left"
    },
    next    : {
    button  : "#morevideos_next",
    key     : "right"
 },                   
});



$('#relatedShows_carousel').carouFredSel();

// Using custom configuration
$('#relatedShows_carousel').carouFredSel({
    circular: true,    
    items               : 3,
    direction           : "left",
    scroll : {
        items           : 3,
        easing          : "elastic",
        duration        : 1000,                         
        pauseOnHover    : true
    },     
    prev    : {
    button  : "#relatedShows_prev",
    key     : "left"
    },
    next    : {
    button  : "#relatedShows_next",
    key     : "right"
 },                   
  });
 });
 </script> 

在这里你可以看到我使用了两个不同的轮播...它需要两个不同的 div,+ 4 个不同的按钮或用于下一个和上一个按钮的 a's ...

first carousel  
#moreVideos_carousel
prev btn - #morevideos_prev
next btn - #morevideos_next


second carpousel
#relatedShows_carousel
prev btn - #relatedShows_prev
next btn - #relatedShows_next

你必须有这样的......

【讨论】:

  • 我不会使用上一个按钮。这应该是向右的连续幻灯片。因为我是 Jquery 的新手,所以我仍然理解你的代码。非常感谢
  • 如果有帮助,请点赞...如果正确,请更正...非常需要高声誉...
  • 我仍在尝试跟进,因为您的脚本与我的示例完全不同。我会在确认它有效后投票。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-10
相关资源
最近更新 更多