php广告图片循环播放 幻灯片效果

WBOY
发布: 2016-07-29 09:15:34
原创
1122 人浏览过



    <meta http-equiv="content-type" c charset="utf-8">
    <title>Image play</title>
    <style><span>        body{
            width:<span>430px;
            margin:<span>20px auto;
        }
        p.<span>now{
            display:<span>block;
            width:<span>400px;
            height:<span>200px;
            overflow:<span>hidden;
            border:1px solid <span>#<span>ccc;<span>        }
        li.<span>now{
            color:<span>#<span>ccc;<span>        }
        li{
            <span>list-style:<span>none;
            <span>float:<span>left;
            padding:0<span> 10px;
            margin-bottom:<span>5px;
            border:1px solid <span>#<span>ccc;            background:<span>#<span>eee;<span>        }
        <span>#<span>fd{<span>list-style:<span>none;
            <span>float:<span>left;
            padding:0<span> 10px;
            border:1px solid <span>#<span>ccc;            margin:0<span> auto;
            background:<span>#<span>eee;<span>        }
        img{
            width:<span>400px;
            height:<span>200px;
            padding:<span>1px;
            <span>/*<span>padding-top:18px;<span>*/<span>        }
    </style>


<div>
    <p>class="now"><img  src="./images/pic1.jpg" alt="php广告图片循环播放 幻灯片效果" ></p>
    <p><img  src="./images/pic2.jpg" alt="php广告图片循环播放 幻灯片效果" ></p>
    <p><img  src="./images/pic3.jpg" alt="php广告图片循环播放 幻灯片效果" ></p>
    <p><img  src="./images/pic4.jpg" alt="php广告图片循环播放 幻灯片效果" ></p>
    <ul>
        <li>class="now">1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
</div>
<script>
    <span>var tags=$("fd").getElementsByTagName("li"); <span>//<span> 获取切换按钮节点<span>var cats=$("fd").getElementsByTagName("p"); <span>//<span> 获取切换内容节点<span>var<span>current; <span>//<span> 高置当前帧的变量宣容器<span>var timer=2000; <span>//<span> 设置2秒循环一次<span>function<span> disAll(){
        <span>for(<span>var i=0; i<tags.length; i++<span>){
            tags[i].className=""<span>;
            cats[i].className=""<span>;
            cats[i].style.display="none"<span>;
        }
    }
    <span>function<span> setNow(){
        <span>for(<span>var i=0; i<tags.length; i++<span>){
            <span>if(tags[i].className=="now"<span>){
                <span>current=<span>i;
            }
        }
    }
    <span>for(<span>var j=0; j<tags.length; j++<span>){
        tags[j].>function<span>(){
            clearInterval(h);
            disAll();
            this.className="now"<span>;
            setNow();
            cats[<span>current].style.display="block"<span>;
            cats[<span>current].className="now"<span>;
        }
        tags[j].>function<span>(){
            setNow();
            h=setInterval("goNext()", 3000<span>);
        }
    }
    <span>function<span> goNext(){
        setNow();
        <span>current+=1<span>;
        <span>if(<span>current>=parseInt(tags.<span>length)){
            <span>current=0<span>;
            disAll();
            cats[0].style.display="block"<span>;
            tags[0].className="now"<span>;
            cats[0].className="now"<span>;
        }<span>else<span>{
            disAll();
            cats[<span>current].style.display="block"<span>;
            cats[<span>current].className="now"<span>;
            tags[<span>current].className="now"<span>;
        }
    }
    <span>var h=setInterval("goNext()",<span> timer);
    <span>function<span> $(obj){
        <span>return document.<span>getElementById(obj);
    }
</script>

登录后复制

以上就介绍了php广告图片循环播放 幻灯片效果,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板