PHP數(shù)組函數(shù)array_intersect_key()的用法
639
2024-01-03
jQuery實(shí)現(xiàn)圖片向左向右切換效果的簡單實(shí)例
<div class="imageRotation container"> <div class="imageBox"> <img src="http://www.gimoo.net/t/1903/images/chugui.jpg"> <img src="http://www.gimoo.net/t/1903/images/ad_auto.jpg"> <img src="http://www.gimoo.net/t/1903/images/ad_home.jpg"> <img src="http://www.gimoo.net/t/1903/images/ad_nba.jpg"> <img src="http://www.gimoo.net/t/1903/images/ad_stock.jpg"> <img src="http://www.gimoo.net/t/1903/images/ad_yuetu.jpg"> </div> <div class="iconBox"> <span rel="1" class="active">1</span> <span rel="2">2</span> <span rel="3">3</span> <span rel="4">4</span> <span rel="5">5</span> <span rel="6">6</span> </div> </div> //CSS樣式 .container { width: 1000px; margin: 0 auto; } .imageRotation { width: 1000px; height: 480px; position: relative; overflow: hidden; margin-top: 8px; } .imageBox { position: absolute; overflow: hidden; display: block; height: 480px; } .imageBox img { width: 1000px; height: 480px; float: left; border: none; display: block; } .iconBox { position: absolute; width: 120px; height: 12px; line-height: 12px; top: 444px; right: 20px; text-align: center; } .iconBox span { width: 6px; height: 6px; border-radius: 10px; text-align: center; background: #555; border: 2px solid #f5f5f5; float: left; text-indent: -999em; margin-left: 5px; cursor: pointer; } .iconBox span.active { width: 6px; height: 6px; background: #820000; border-radius: 10px; text-align: center; text-indent: -999em; } //js邏輯 $(function() { $(".imageRotation").each(function() { var imageRotation = this, imageBox = $(imageRotation).children(".imageBox"), iconBox = $(imageRotation).children(".iconBox"), iconArr = $(iconBox).children(), imageWidth = $(imageRotation).width(), imageNum = $(imageBox).children().size(), imageRollWidth = imageWidth * imageNum, activeID = parseInt($($(iconBox).children(".active")).attr("rel")), nextID = 0; var setIntervalID, setIntervalTime = 3000, speed = 500; //設(shè)置 圖片容器 的寬度 $(imageBox).css({ 'width': imageRollWidth + "px" }); //圖片切換函數(shù) function imageRoll(clickID) { if (clickID) { nextID = clickID; } else { if (activeID <= 5) { nextID = activeID + 1 } else { nextID = 1; } } //圖標(biāo)添加樣式、刪除樣式 $(iconArr[activeID - 1]).removeClass("active"); $(iconArr[nextID - 1]).addClass("active"); $(imageBox).animate({ left: "-" + (nextID - 1) * imageWidth + "px" }, speed); activeID = nextID; } setIntervalID = setInterval(imageRoll, setIntervalTime); //鼠標(biāo)移動(dòng)事件 $(imageBox).hover(function() { clearInterval(setIntervalID); }, function() { setIntervalID = setInterval(imageRoll, setIntervalTime); }); //鼠標(biāo)點(diǎn)擊事件 $(iconArr).click(function() { clearInterval(setIntervalID); var clickID = parseInt($(this).attr("rel")); //獲取當(dāng)前點(diǎn)擊圖片的id imageRoll(clickID); setIntervalID = setInterval(imageRoll, setIntervalTime); }); }); });
以上這篇jQuery實(shí)現(xiàn)圖片向左向右切換效果的簡單實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持綠夏網(wǎng)。
#免責(zé)聲明#
本站[綠夏技術(shù)導(dǎo)航]提供的一切軟件、教程和內(nèi)容信息僅限用于學(xué)習(xí)和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請用戶自負(fù)。本站信息來自網(wǎng)絡(luò)收集整理,版權(quán)爭議與本站無關(guān)。您必須在下載后的24個(gè)小時(shí)之內(nèi),從您的電腦或手機(jī)中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請支持正版,購買注冊,得到更好的正版服務(wù)。我們非常重視版權(quán)問題,如有侵權(quán)請郵件[admin@lxwl520.com]與我們聯(lián)系進(jìn)行刪除處理。敬請諒解!