简体   繁体   中英

Making image slider work automatically

I have imported a image slider into my webpage. It works fine but doesn't work automatically. I have tried to add some jquery that makes the image change after 4 seconds but for some reason it only works once and goes to the last image in the list. Can someone show me where I am going wrong and help me to make the slider work on its own.

Here is the mark-up...

<ul id="body">
<input type="radio" name="radio-btn" id="img-1" checked />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/blackscale.jpg">
    </div>
    <label for="img-6" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-2" class="sb-bignav" title="Next">&#x203a;</label>
</li>

<input type="radio" name="radio-btn" id="img-2" />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/huf.jpg">
    </div>
    <label for="img-1" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-3" class="sb-bignav" title="Next">&#x203a;</label>
</li>

<input type="radio" name="radio-btn" id="img-3" />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/palace.jpg">
    </div>
    <label for="img-2" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-4" class="sb-bignav" title="Next">&#x203a;</label>
</li>

<input type="radio" name="radio-btn" id="img-4" />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/skatecafe.jpg">
    </div>
    <label for="img-3" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-5" class="sb-bignav" title="Next">&#x203a;</label>
</li>

<input type="radio" name="radio-btn" id="img-5" />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/only.jpg">
    </div>
    <label for="img-4" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-6" class="sb-bignav" title="Next">&#x203a;</label>
</li>
<input type="radio" name="radio-btn" id="img-6" />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/supreme.jpg">
    </div>
    <label for="img-5" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-7" class="sb-bignav" title="Next">&#x203a;</label>
</li>
<input type="radio" name="radio-btn" id="img-7" />
<li id="img-container">
    <div id="img-inner">
        <img src="file:///C:/smilburn/Practices/images/adidas.jpg">
    </div>
    <label for="img-6" class="sb-bignav" title="Previous">&#x2039;</label>
    <label for="img-8" class="sb-bignav" title="Next">&#x203a;</label>
</li>

Here is the jquery I have added..

function gogo(){
    $('label[title="Next"]').click();
}
$(document).ready(function () {
    setInterval('gogo()',4000);
});

Try this out.. easy to work with slider plugins

http://bxslider.com/

or this

http://rhinoslider.com

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