/*
ww 图片宽度
id table ID
*/
代码应用实例 化妆品护肤DiY的广告界面
function moveleft(id,ww) {
var stopKey = true;
if(ww== undefined){ ww=215;}
var maxTdIndex=$('#'+id+' td').length-1;
var mf = function () {
if (stopKey) { $('#'+id ).animate({ marginLeft: -ww }, 1000, function () {
$('#'+id ).css({ marginLeft: 0 });
$('#'+id+' td:eq(0)').insertAfter($('#'+id+' td:eq('+ maxTdIndex +')'));
});}
}
var tf = setInterval(mf, 3000);
$('#'+id ).hover(function () { stopKey = false; }, function () { stopKey = true; });
}
<div style="border:1px solid #ccc; height:158px; width:835px; overflow:hidden; margin-left:55px; " id="shoplist">
<table id="mt"> <tr>
<td><img src="images/shop1.jpg" /></td>
<td><img src="images/shop2.jpg" /></td>
<td><img src="images/shop3.jpg" /></td>
<td><img src="images/shop4.jpg" /></td>
<td><img src="images/shop5.jpg" /></td>
<td><img src="images/shop6.jpg" /></td>
<td><img src="images/shop7.jpg" /></td>
<td><img src="images/shop8.jpg" /></td>
<td><img src="images/shop9.jpg" /></td>
<td><img src="images/shop10.jpg" /></td>
</tr></table>
<script type="text/javascript"> moveleft('mt',215); </script>
</div>