JQuery循环插件无法正常工作

时间:2013-03-10 04:10:02

标签: javascript jquery jquery-cycle

我正在尝试使用'淡入淡出'过渡效果将jquery Cycle幻灯片插件添加到我的页面。但我还是无法让它发挥作用。

这是我的HTML:

<div class="container">
    <div class="slide1">
         <blockquote>
            <span class="leftquotes">&ldquo;</span> He promptly completed the task at hand and communicates really well till the project reaches the finishing line. I was pleased with his creative design and will definitely be hiring him again. <span class="rightquotes">&bdquo; </span>
         </blockquote>
         <img src="images/profile.jpg" width="120" height="100" />
         <h2>Steve Kruger</h2>
         <h6>UI/UX Designer at Woof Design Studio</h6>
         <div class="slide1bottom"></div>
    </div>

    <div class="slide2">
        <blockquote>
            <span class="leftquotes">&ldquo;</span> Till the project reaches the finishing line. I recommend him to anyone who wants their work done professionally. project reaches the finishing line. I recommend him to anyone who wants their work done professionally. The project ... <a href="#"> read more</a><span class="rightquotes">&bdquo; </span>
        </blockquote>
        <img src="images/images.jpg" width="120" height="100" />
        <h2>John Doe</h2>
        <h6>Developer Relations at Woof Studios</h6>
        <div class="slide2bottom"></div>
    </div>

    <div class="slide3">
        <blockquote>
            <span class="leftquotes "> &ldquo;</span> He promptly completed the task at hand and communicates really well till the project reaches the finishing line. I was pleased with his creative design and will definitely be hiring him again. <span class="rightquotes">&bdquo; </span>
        </blockquote>
        <img src="images/summer_school.png" width="120" height="100" />
        <h2>Steve Stevenson</h2>
        <h6>CEO Woof Web Design Studios</h6>
        <div class="slide3bottom"></div>
    </div>  
</div>

这是我的JQuery:

$(function() {
    $('#container').cycle();
});

我已正确导入JQuery插件,循环插件和简化插件到我的页面。

<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.color.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="jscript/jquery.easing.1.3.js"></script>

这是我的小提琴:http://jsfiddle.net/kRZ5r/

3 个答案:

答案 0 :(得分:1)

您指定用于初始化cycle的选择器在查找id时正在寻找class

$('.container').cycle({
   timeout: 10000
});

小提琴here

答案 1 :(得分:1)

你有这个标记:

<div class="container">

然而你使用这个选择器:

$('#container').cycle();

#用于id选择器,您需要使用.,这是class选择器:

$('.container').cycle();

值得注意的是,Alsup先生发布了一个闪亮的新更新, Cycle2 http://www.malsup.com/jquery/cycle2/),与HTML5兼容并可以利用data-属性进行自动初始化

答案 2 :(得分:1)

在html代码中,您提到了一个容器作为类。但在JQuery中,您使用#将其定义为id。

<div class="container">
</div>

$(function() {
    $('.container').cycle();
});