這篇文章將為大家詳細(xì)講解有關(guān)js如何實(shí)現(xiàn)圖片輪播特效,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括天柱網(wǎng)站建設(shè)、天柱網(wǎng)站制作、天柱網(wǎng)頁(yè)制作以及天柱網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,天柱網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到天柱省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
先看一眼效果圖:
代碼:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> *{padding:0;margin:0;} #content{width:550px;height:300px;margin:50px auto;position:relative;} #content input{width:60px;height:30px;margin-right:10px;} #content div{diplay:inline-block;position:absolute;bottom:0;;border:1px solid #ccc;width:250px;height:250px;background:url(img/loader_ico.gif) no-repeat center #f1f1f1;} #content div.left{left:0;} #content div.right{right:0;} #content div span{display:inline-block;width:250px;height:30px;line-height:30px;background:#ccc;color:red;text-align:center;} #content div img {height:250px;width:250px;} </style> <script> window.onload = function () { var content = $('content'),prev = $('prev'),next = $('next'), left = $('left'),right = $('right'); var aSpan = content.getElementsByTagName('span'); var aImg = content.getElementsByTagName('img'); var arr = [ ['img/1.png','img/2.png','img/3.png','img/4.png'], ['img/2.png','img/3.png','img/4.png'] ]; var num = [0, 0]; // 初始化 for ( var i = 0; i < aSpan.length; i++ ) { carousel(i); aImg[i].index = i; aImg[i].onclick = function () { if (num[this.index] === arr[this.index].length - 1) num[this.index] = -1; num[this.index]++; carousel(this.index); } } // 下一組 next.onclick = function () { for ( var i = 0; i < aSpan.length; i++ ) { if (num[i] === arr[i].length - 1) num[i] = -1; num[i]++; carousel(i); } } // 上一組 prev.onclick = function () { for ( var i = 0; i < aSpan.length; i++ ) { if (num[i] === 0) num[i] = arr[i].length; num[i]--; carousel(i); } } function carousel(index) { aSpan[index].innerHTML = num[index] + 1 + ' / ' + arr[index].length; aImg[index].src = arr[index][num[index]]; } function $(id) {return document.getElementById(id);} } </script> </head> <body> <div id="content"> <input type="button" value="上一組" id="prev" /> <input type="button" value="下一組" id="next" /> <div class="left"> <span>圖片數(shù)量加載中</span> <img /> </div> <div class="right"> <span>圖片數(shù)量加載中</span> <img /> </div> </div> </body> </html>
關(guān)于“js如何實(shí)現(xiàn)圖片輪播特效”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
分享題目:js如何實(shí)現(xiàn)圖片輪播特效
當(dāng)前URL:http://chinadenli.net/article46/pgoihg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、面包屑導(dǎo)航、Google、全網(wǎng)營(yíng)銷推廣、網(wǎng)頁(yè)設(shè)計(jì)公司、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)