如何在我的Javascript/Jquery Slider中添加按钮? [英] How do I add buttons to my Javascript/Jquery Slider?

查看:89
本文介绍了如何在我的Javascript/Jquery Slider中添加按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个javascript/jquery图片滑块.每个幻灯片都是一个< div>元素,div容器"的子级.每五秒钟,最后一张幻灯片向上滑动,新图像逐渐淡入.简单的操作.这是我的代码:

So I have a javascript/jquery image slider. Each slide is a <div> element, children of the div "container". Every five seconds, the last slide slides up and the new image fades in. Simple stuff. Here's my code:

window.onload = function start() {
    slide();
}

function slide() {
    var num = 0;
    window.setInterval(function () {
        $("#container div:eq(" + num + ")").slideUp(450);
        num = (num + 1) % 4;
        $("#container div:eq(" + num + ")").fadeIn(450);

    }, 5000);

那么,我需要做些什么来添加将您带到下一张幻灯片和最后一张幻灯片的按钮?

So, what do I need to do to add buttons that take you to the next slide and last slide?

推荐答案

下一步:

$("#next").click(function () {
    $("#container div:eq(" + num + ")").slideUp(450);
    num = (num + 1) % 4;
    $("#container div:eq(" + num + ")").fadeIn(450);
});

最后一个:

$("#last").click(function () {
    $("#container div:eq(" + num + ")").slideUp(450);
    num = 4;
    $("#container div:eq(" + num + ")").fadeIn(450);
});

这篇关于如何在我的Javascript/Jquery Slider中添加按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆