图片切换(小数量)

图片切换小数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<script type="text/javascript">
    window.onload = function(){
        var oPrev = document.getElementById('prev');
        var oNext = document.getElementById('next');
        var oText = document.getElementById('text');
        var oSpan = document.getElementById('span1');
        var oImg = document.getElementById('img1');
        var arrUrl = ['../images/1.jpg','../images/2.jpg','../images/3.jpg','../images/4.jpg','../images/5.jpg','../images/6.jpg'];
        var arrText = ['图片1','图片2','图片3','图片4','图片5','图片6'];

        var num = 0;

        function fnTab(){
            oSpan.innerHTML = num + 1 + '/' + arrText.length;
            oImg.src = arrUrl[num];
            oText.innerHTML = arrText[num];
        }
        fnTab();
        oNext.onclick = function(){
            num ++;
            if ( num == arrText.length ) {
                num = 0;
            };
        fnTab();
        }
        oPrev.onclick = function(){
            num --;
            if ( num == -1 ) {
                num = arrText.length-1;
            };
        fnTab();
        }
    }

</script>
<style type="text/css">
    #content {
        width: 400px;
        height: 400px;
        border: 5px solid #f1f1f1;
        margin: 40px auto 0;
        position: relative;
        background: #f1f1f1;
    }
    #content a {
        width: 40px;
        height: 40px;
        background: #444;
        border: 2px solid #fff;
        position: absolute;
        top: 178px;
        line-height: 40px;
        text-decoration: none;
        text-align: center;
        color: #fff;
        font-weight: bold;
        font-size: 30px;
        opacity: 0.4;filter:alpha(opacity:40);
    }
    #content a:hover {
        opacity: 0.8;filter:alpha(opacity:80);
    }
    #prev {
        left: 10px;
    }
    #next {
        right: 10px;
    }
    #text,#span1 {
        position: absolute;
        left: 0;
        width: 400px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        color: #fff;
        background: #000;
        opacity: 0.4;filter:alpha(opacity:0.4);
    }
    #text {
        bottom: 0;
        margin: 0;
    }
    #span1 {
        top: 0;
    }
    #img1 {
        width: 400px;
        height: 400px;
    }
</style>
</head>
<body>
    <div id="content">
        <a id="prev" href="javascript:;"><</a>
        <a id="next" href="javascript:;">></a>
        <p id="text">图片加载中……</p>
        <span id="span1">数量加载中……</span>
        <img id="img1" />
    </div>
</body>
</html>

可以一张纸切换并回到开始

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值