简体   繁体   中英

JQuery cycle plugin not working

I am trying to add jquery Cycle slideshow plugin to my page with 'fade' transition effect. But still I couldn't make it to work.

This is my 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>

This is my JQuery :

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

I have imported JQuery plugin, cycle plugin and easing plugin to my page properly.

<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>

This is my fiddle : http://jsfiddle.net/kRZ5r/

The selector you have specified for initializing cycle is looking for an id when it should be looking for a class .

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

Fiddle here

You have this markup:

<div class="container">

Yet you use this selector:

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

# is used for id selectors, You would need to use . , which is the class selector:

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

It's also worth noting that Mr. Alsup has released a shiny new update, Cycle2 ( http://www.malsup.com/jquery/cycle2/ ), that is HTML5 compatible and can leverage data- attributes for automagic initialization.

In the html code you mention a container as a class. but in the JQuery you use # to define it as a id.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM