最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

很棒的一組js圖片輪播特效

 更新時(shí)間:2017年01月12日 17:20:51   作者:光明大神棍  
這篇文章主要為大家分享了一款很棒的js組輪播特效,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

大家經(jīng)常在網(wǎng)頁(yè)中使用輪播效果,本文為大家分享的是一組圖片輪播特效,希望大家喜歡

先看一眼效果圖:

代碼:

<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>

精彩專題分享:jQuery圖片輪播 JavaScript圖片輪播 Bootstrap圖片輪播

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

长乐市| 霞浦县| 宜兰县| 乌拉特后旗| 宝兴县| 华宁县| 沾益县| 盐山县| 灵山县| 星座| 无棣县| 新乐市| 甘泉县| 蒙城县| 类乌齐县| 绥芬河市| 武强县| 灵丘县| 灯塔市| 嘉祥县| 福安市| 潮州市| 韩城市| 普陀区| 龙南县| 三明市| 东阳市| 嘉祥县| 光泽县| 江源县| 阿鲁科尔沁旗| 菏泽市| 广丰县| 湖北省| 江门市| 浪卡子县| 博白县| 盐城市| 若尔盖县| 新蔡县| 衡山县|