JQuery循環(huán)滾動圖片代碼
更新時間:2011年12月08日 23:19:46 作者:
每次滾動的長度不要固定死,可以直接獲取圖片寬度作為滾動的長度。這樣當你的網站有很多地方需要這個效果的時候一個函數就可以搞定了
復制代碼 代碼如下:
function refresh() {
var s = $(".box1");
if (!s.is(":animated"))
$(".box1").animate({ marginLeft: "0px" }, "slow", function () {
$('.box1 img:first').before($('.box1 img:last'));
$(".box1").css("margin-left", "-206px");
});
}
<div class="frame"><div class="box1"><img src="img/001.png" alt="" /><img src="img/002.png" alt="" /><img src="img/003.png" alt="" /><img src="img/004.png" alt="" /></div></div>
<button type="button"><<</button><button type="button" onclick="refresh()">>></button>
.box1
{
width:1200px;
overflow:hidden;
margin-left:-206px;
}
.frame
{
width:620px;
overflow:hidden;
}
圖片寬度默認206px,沒設定
相關文章
jQuery中DOM節(jié)點刪除之empty與remove
DOM節(jié)點刪除相信對每個初學jQuery的新手們來說都不陌生,下面這篇文章主要介紹了jQuery中DOM節(jié)點刪除之empty與remove的相關資料,有需要的朋友可以參考借鑒,感興趣的下面來一起學習學習吧。2017-01-01