질문이나 더 좋은 의견, 제안 사항이 있으시면 마지막에 메시지를 남겨주시면 감사하겠습니다. 구체적인 코드는 다음과 같습니다. 코드를 복사하세요 코드는 다음과 같습니다. 图片轮换效果 <br>body, div { margin: 0; paading: 0; font-size: 12px; } <br>ul, li { margin: 0; padding: 0; list-style: none; } <br>.clear { clear: both; width: 1px; height: 0px; line-height: 0px; font-size: 1px; } <br>.left { float: left; } <br>.right { float: right; } <br>ul, li { margin: 0; padding: 0; list-style: none; } <br>.box { width: 960px; margin: 0 auto; padding-top: 15px; } <br>.flash { position: relative; width: 360px; height: 280px; overflow: hidden; } <br>.list { position: relative; width: 360px; height: 260px; overflow: hidden; } <br>.list li img{ position: absolute; left: 0; top: 0; width: 360px; height: 260px;} <br>.list li { display: none; } <br>.list .over { display: block;} <br>.btn { position: absolute; top: 233px; width: 360px; height: 26px; background: #000; line-height: 26px; opacity: 0.7; filter: alpha(opacity=70); text-align: right; } <br>.btn a { padding: 2px 5px; margin: 0 2px; border: 1px solid #fff; border-radius: 2px; background: #000; color: #fff; text-decoration: none; cursor: pointer; } <br>.btn .over { background: #f00; } <br>.btn2 { position: absolute; top: 206px; height:62px; } <br>.btn2 img { width: 70px; height: 60px; border: 1px solid #ccc; } <br>.btn2 .over img { border: 1px solid #f00; } <br>.flash2 { position: relative; width: 800px; } <br>.flash2 .list { float: left; } <br>.flash2 .btn2 { float: left; position: static; width: 150px; height: 280px; } <br>.flash2 .btn2 img { width: 120px; height: 47px; } <br> <br>var autoPlay = { <br>setTimeShow: function(showObj, btnObj, showClass, timer) { <br>var length = btnObj.length; <br>var timeId = null; <br>var index = 0; <br>if(showObj.length == btnObj.length) { <br>timeId = window.setInterval(function(){ <br>index = autoPlay.showCon(showObj, btnObj, showClass, index); //返回操作后的index <br>}, timer); <br>} else if (length == 1) { <br>clearInterval(timeId); // 如果只有一张图片,则清除计时器,停止自动播放。 <br>} else { <br>return false; <br>} <br>// 鼠标点击的操作。 <br>btnObj.each(function(i) { <br>$(this).click(function() { <br>$(this).addClass(showClass); <br>btnObj.not($(this)).removeClass(showClass); <br>showObj.eq(i).show('slow'); <br>showObj.not(showObj.eq(i)).hide(); <br>index = i; <br>}); <br>}); <br>}, <br>//自动轮换显示 <br>showCon: function(show, btnObj, showClass, index) { <br>btnObj.eq(index).addClass(showClass); <br>btnObj.not(btnObj.eq(index)).removeClass(showClass); <br>show.eq(index).show('slow'); <br>show.not(show.eq(index)).hide(); <br>if (index >= btnObj.length -1) { <br>index = 0; <br>} else { <br>index++; <br>} <br>return index; //返回操作后的index <br>}, <br>}; <br> <br>$(document).ready(function() { <br>autoPlay.setTimeShow($('#list1 li'), $('#btn1 a'), 'over', 3000); <br>autoPlay.setTimeShow($('#list2 li'), $('#btn2 a'), 'over', 3000); <br>autoPlay.setTimeShow($('#list3 li'), $('#btn3 a'), 'over', 3000); <br>}); <br> 12345 < img src="images/2.jpg"/>< a href="#"> < img src="images/2.jpg"/>< a href="#">