新年好各位,这特效如何完善到呢?
~~~首先给大家拜个年,祝各位在新的一年马上有钱,马上有亲~~~
目前下面的代码实现的是 点击小图标变换的,我想让它自动变换,当然也保留点击变换,该怎么做哦, 求指点:
<div id="banner1" class="banner"><img src="images/brand1.jpg" id="ban_src"/></div>
<div id="banner2" class="banner" style="display:none"><img src="images/brand2.jpg" id="ban_src"/></div>
<div id="banner3" class="banner" style="display:none"><img src="images/brand3.jpg" id="ban_src"/></div>
<div id="banner4" class="banner" style="display:none"><img src="images/brand4.jpg" id="ban_src"/></div>
<div id="banner5" class="banner" style="display:none"><img src="images/brand5.jpg" id="ban_src"/></div>
<div id="banner6" class="banner" style="display:none"><img src="images/brand6.jpg" id="ban_src"/></div>
<div id="banner7" class="banner" style="display:none"><img src="images/brand1.jpg" id="ban_src"/></div>
<div id="adv_burr">
<ul>
<li class="locat" onClick="rebanner(1)" id="adv_burr1"><img src="images/banbur1.jpg" /></li>
<li onClick="rebanner(2)" id="adv_burr2"><img src="images/banbur2.jpg" /></li>
<li onClick="rebanner(3)" id="adv_burr3"><img src="images/banbur3.jpg" /></li>
<li onClick="rebanner(4)" id="adv_burr4"><img src="images/banbur4.jpg" /></li>
<li onClick="rebanner(5)" id="adv_burr5"><img src="images/banbur5.jpg" /></li>
<li onClick="rebanner(6)" id="adv_burr6"><img src="images/banbur6.jpg" /></li>
<li onClick="rebanner(7)" id="adv_burr7" style="margin-right:0;"><img src="images/banbur7.jpg" /></li>
</ul>
</div>
JS:
function rebanner(d){
for(var i=1;i<=7;i++)
{
if(i==d)
{
$("#ban_src").attr("src","images/ad2.jpg");
$("#banner"+i).fadeIn(500);
$("#adv_burr"+i).attr("class","locat");
}
else
{
$("#banner"+i).hide(0);
$("#adv_burr"+i).attr("class","");
}
}
}
------解决方案-------------------- var timer, nowindex = 1, delay = 3000;
function rebanner(d) {
///////////////
if (d !== undefined) {
clearInterval(timer);
nowindex = d;
}
else {
nowindex++;
if (nowindex > 7) nowindex = 1;
}
///////////////
for (var i = 1; i <= 7; i++) {
if (i == nowindex) {///////////////
$("#ban_src").attr("src",