简体   繁体   English

Jquery图像库下一个/ prev图像按钮

[英]Jquery image gallery next/prev image buttons

<div class="slider">
    <ul id="slider1">
        <li>
            <img src="images/contimg.jpg" width="500" height="400" border="0">
        </li>
        <li>
            <img src="images/contimgtwo.jpg" width="500" height="334" border="0">
        </li>
    </ul>
</div>
<div id="buttons">
    <button>click</button>
</div>

Javascript 使用Javascript

$(document).ready(function () {
    $('#slider1').cycle({
        fx: 'fade',
        speed: 'slow',
        timeout: 5000
    });
});

$(function () {
    $("button").click(function () {
        $("#slider1").length + 1;
    });
});

I'm using a cycle plugin to make the images from the fade every 5 secs. 我正在使用循环插件每隔5秒从淡入淡出制作图像。 I wanted to add next/prev image buttons. 我想添加next / prev图像按钮。 The first piece of js is the plugin which automates the 'slideshow' and the second bit is the js for the buttons to change images next/prev. js的第一部分是自动播放“幻灯片”的插件,第二部分是用于按钮更改下一张/上一张图像的js。

may this help you 这可能对你有所帮助

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

    $('#slider1').cycle({
        fx: 'fade',
        speed:  'slow', 
        timeout: 5000
        prev:    '#prev',
        next:    '#next',
        pager:   '#nav',
        pagerAnchorBuilder: pagerFactory
    });

    function pagerFactory(idx, slide) {
        var s = idx > 2 ? ' style="display:none"' : '';
        return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
    };

});
</script>

just add html to your page 只需将html添加到您的页面即可

<a href="#"><span id="prev">Prev</span></a> 
 <a href="#"><span id="next">Next</span></a>
 <div id='nav'></div>
// doc ready
$(function() {
    $('#slider').cycle({
        fx:     'fade', 
        speed:  'slow', 
        timeout: '5000', 
        next:   '#next-arrow', // id name next
        prev:   '#prev-arrow' // id name prev
    });

    $(window).load(function(
        // your div next name
        $('#next-arrow').append('<img src="http://iconify.it/wp-content/icons-large-alt/arrow-right.png" style="width:25px;"/>')

        // your div prev name
        $('#prev-arrow').append('<img src="http://iconify.it/wp-content/icons-large-alt/arrow-right.png" style="width:25px; -webkit-transform:rotate(180deg);"/>')
    });
});

Hope is help you guy. 希望能帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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