京东网轮播图效果(能自动轮播)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
	*{
		padding: 0px;
		margin: 0px;
	}
	#box{
		margin: 30px auto;
		/*border: 2px solid red;*/
		height: 240px;
		width: 670px;
		overflow: hidden;
		position: relative;
	}
	#box img{
		width:670px;
		height:240px;
		position:absolute;
		left:0px;
		top:0px;
		opacity:0;
		filter:alpha(opacity=0);
	}
	.main .page{
		height: 30px;
		width: 190px;
		z-index: 10;
		position: absolute;
		top: 208px;
		left: 480px;
	}
	.main  .page a{
				display:inline-block;
				width:22px;
				height:22px;
				line-height: 22px;
				background:url(./images/num_grey.png) no-repeat 0px 0px;
				margin:0px 4px;
				float:left;
				color:#FFF;
				text-decoration:none;
				text-align:center;
			}
			.main  .page a.active{
				background:url(./images/num_red.png) no-repeat 0px 0px;
			}
</style>
<script src="./js/jquery.js"></script>
<script type="text/javascript">
  window.onload = function(){
  	 var box = document.getElementById('box');
  	 var img= box.getElementsByTagName('img');
  	 var a= document.getElementsByTagName('a');
  	 var c=0;
     function run(){

         c++;
            if(c==6){
       	    c=0;
         }
       for(var i=0;i<7;i++){
             if(i==c){
             	   img[i].style.opacity= 1;
             	   a[i].className='active';
          }else{
             	   img[i].style.opacity= 0;
                 a[i].className+='no';
           }
      }

     }

  	var timer=setInterval(run,1000);
   $(function(){
        var apage=$('.main .page a');
        var aimg=$('#box img');
        var index=0;
        apage.click(function(){ 
        	index=$(this).index();
        	  change();
        });
        function change(){
        	apage.removeClass('active');
		   	  apage.eq(index).addClass('active');
        	aimg.eq(index).siblings().stop().animate({
        		opacity: 0
        	},300)
        	aimg.eq(index).stop().animate({
        		opacity: 1
        	},300)
        }
	})
 }
</script>
</head>
<body>
<div id="box">
   <img style="opacity:1;filter:alpha(opacity=100);" src="./images/1.jpg" alt="" />	
   <img src="./images/2.jpg" alt="" />	
   <img src="./images/3.jpg" alt="" />	
   <img src="./images/4.jpg" alt="" />	
   <img src="./images/5.jpg" alt="" />
   <img src="./images/6.jpg" alt="" />
   </div>
   <div class="main">
   <p class="page">
   	<a class="active" href="javascript:void(0);">1</a>
   	<a href="javascript:void(0);">2</a>
   	<a href="javascript:void(0);">3</a>
   	<a href="javascript:void(0);">4</a>
   	<a href="javascript:void(0);">5</a>
   	<a href="javascript:void(0);">6</a>
   </p>	
</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值