• 自动切换焦点图


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>自动切换焦点图</title>
    <style>
    ul{margin:0;padding:0;}
    li{list-style:none;}
    body{background:#333;}
    #pic{400px;height:500px;position:relative;margin:0 auto;}
    #pic img{400px;height:500px;}
    #pic ul{40px;position:absolute;top:0;right:-50px;}
    #pic li{40px;height:40px;margin-bottom:4px;background:#999;}
    #pic li.active{background:#fc3;}
    #pic span,#pic p{position:absolute;left:0;400px;height:30px;line-height:30px;text-align:center;color:#fff;margin:0;background:#000;}
    #pic span{top:0;}
    #pic p{bottom:0;}
    </style>
    </head>
    <body>
    <div id="pic">
    <img src="img/1.jpg" alt="" id="img1">
    <span>数量正在加载中</span>
    <p>文字说明正在加载中.....</p>
    <ul>
    </ul>
    </div>
    </body>
    </html>
    <script>
    window.onload=function(){

    var oDiv=document.getElementById('pic');
    var oImg=document.getElementsByTagName('img')[0];
    var oSpan=document.getElementsByTagName('span')[0];
    var oP=document.getElementsByTagName('p')[0];
    var oUl=oDiv.getElementsByTagName('ul')[0];
    var aLi=oUl.getElementsByTagName('li');

    var arrUrl=['img/1.jpg','img/2.jpg','img/3.jpg','img/4.jpg'];
    var arrText=['图一说明','图二说明','图三说明','图四说明'];
    var num=0;

    ////////////////////////////
    var timer=null;
    function autoPlay(){
    timer=setInterval(function(){
    num++;
    num%=arrText.length;
    fnTab();
    },1000);
    }
    // autoPlay();
    setTimeout(autoPlay,2000);
    ////////////////////////////

    oDiv.onmouseover=function(){
    clearInterval(timer);
    }

    oDiv.onmouseout=autoPlay;

    for(var i=0;i<arrUrl.length;i++){
    oUl.innerHTML+='<li></li>';
    }

    //初始化
    function fnTab(){
    oImg.src=arrUrl[num];
    oSpan.innerHTML=1+num+'/'+arrUrl.length;
    oP.innerHTML=arrText[num];
    for(var i=0;i<aLi.length;i++)
    {
    aLi[i].className='';
    }
    aLi[num].className='active';
    }
    fnTab();

    for(var i=0;i<aLi.length;i++){
    aLi[i].index=i;
    aLi[i].onclick=function(){
    num=this.index;
    fnTab();

    }
    }


    }
    </script>

  • 相关阅读:
    定义Java类的数组的问题
    Ubuntu下将vim配置为Python IDE(转)
    Python数据结构-序列
    Python数据结构-元祖
    Python数据结构-字典
    Python数据结构-序表
    Python的控制结构(转)
    Python面向对象编程
    训练样本集的制作
    matlab读取指定路径下的图像
  • 原文地址:https://www.cnblogs.com/ll-taj/p/6590412.html
Copyright © 2020-2023  润新知