手记

jquery 实现多图轮换

         

<script type="text/javascript">var t;var speed=2;var i=0;function qiehuan(){var size=$("#all").find("div").length;$("#all").find("div").hide();$("#all").find("div").eq(i).show();i = i+1 == size ?0:i+1;t=setTimeout("qiehuan()",speed*1000);}onload=function(){qiehuan();};$(document).ready(function(){$("#all").hover(function(){clearInterval(t);});$("#all").mouseleave(function(){qiehuan();});});</script>  </head>    <body>    <div id="all" >    <div><img width="300" height="240" src="<%=path %>/images/1.jpg" alt="1" /></div>    <div><img width="300" height="240" src="<%=path %>/images/2.gif" alt="2"/></div>    <div><img width="300" height="240" src="<%=path %>/images/Winter.jpg" alt="3"/></div>    </div>  </body>


0人推荐
随时随地看视频
慕课网APP