1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| <!doctype html> <html> <head> <meta charset="utf-8"> <title>图片轮换</title> </head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script> $(function(){
var $this=$(".wyj"); var $li=$this.find(".uls li"); $li.eq(0).show().siblings().hide(); var index=$this.find(".uls li:visible").index(); var lenght=$li.length;
$("#left").click(function(e) { index=index-1; if(index<=0){ index=lenght-1; } $li.eq(index).show().siblings().hide(); }); $("#right").click(function(e) { righ(); });
var righ=function(){ index=index+1; if(parseInt(index)>lenght-1){ index=0; } $li.eq(index).show().siblings().hide();}
timer=setInterval(function(){ righ(); },500); $("#left,#right").hover(function(e) { clearInterval(timer); },function(){ timer=setInterval(function(){ righ(); },500);}) })
</script> <style> *{ margin:0px; padding:0px;} ul li{ list-style:none;} .wyj{ overflow: hidden; position: relative; height:300px; width:800px; height:300px; margin:0 auto; margin-top:100PX; } </style>
<body>
<div class="wyj"> <ul class="uls"> <li ><img src="images/banner_01.jpg"></li> <li ><img src="images/banner_02.jpg"></li> <li><img src="images/banner_03.jpg"></li> <li ><img src="images/banner_04.jpg"></li> </ul> <img src="images/rotaleft.gif" width="26" height="99" id="left" style="position:absolute; left:3px; top:110px; cursor:pointer;"> <img src="images/rotaright.gif" width="26" height="99" id="right" style="position:absolute; right:3px; top:110px; cursor:pointer;"> </div>
</body> </html>
|