其中如果有问题,有更好的意见或者建议都可在最后留言,都将对您感激不尽。 具体的代码如下: 复制代码 代码如下: 图片轮换效果 <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