以下代码实质上是为横幅设置动画。横幅每五秒交换一次,图像映射也是如此。我想要实现的是,当用户将鼠标悬停在横幅上时,五秒倒计时暂停(或重置),直到用户将鼠标光标从悬停中移开。
我还希望它能够早于 IE8 兼容,至于平板电脑/移动设备,我认为这不会很好地工作,因此稍后会寻找解决方法。
考虑:
$(function () {
$('.fadein img:gt(0)').hide();
setInterval(function () {
$('.fadein :first-child').fadeOut().next('img').fadeIn().end().appendTo('.fadein');
}, 5000);
});
和:
.fadein {
display: block;
margin:auto;
height: 49px;
width:100%;
}
.fadein img {
position:absolute;
}
和:
<div class="fadein">
<img src="http://www.boohoo.com/content/ebiz/boohoo/resources/images/topbanners/Offer_Strip_GBP_v1.jpg" usemap="#secondM" border="0" width="964" height="49" alt="" style="" id="level2Menu"/>
<img src="http://www.boohoo.com/content/ebiz/boohoo/resources/images/topbanners/Offer_Strip_EUR_v1.jpg" usemap="#secondM2" border="0" width="964" height="49" alt="" style="" id="level2Menu"/>
</div>
<map name="secondM">
<area shape="rect" coords="0,0,285,44" href="#" alt="New In" title="New In" />
<area shape="rect" coords="289,0,671,44" href="#" alt="Delivery Details" title="Delivery Details" />
<area shape="rect" coords="676,0,960,44" href="#" alt="Unidays" title="Unidays" />
</map>
<map name="secondM2">
<area shape="rect" coords="0,0,285,44" href="#" alt="New In2" title="New In2" />
<area shape="rect" coords="289,0,671,44" href="#" alt="Delivery Details2" title="Delivery Details2" />
<area shape="rect" coords="676,0,960,44" href="#" alt="Unidays2" title="Unidays2" />
</map>
你可以在这里看到一个工作小提琴:http: //jsfiddle.net/fEXEg/1/
有什么建议么?