JS實現(xiàn)touch 點擊滑動輪播實例代碼
更新時間:2017年01月19日 15:52:25 作者:叫我多多醬
這篇文章主要介紹了JS實現(xiàn)touch 點擊滑動輪播實例代碼,需要的朋友可以參考下
廢話不多說了,直接給大家貼js代碼了,具體代碼如下所示:
<script src="../js/jquery-1.8.3.min.js"></script>
<script src="../js/jQuery.mobile-1.3.2.min.js"></script>
----------------------需要應(yīng)用jquery .mobile自行百度
.num-zcon{
overflow: hidden;
width:auto;
height: 12.5em;
}
.num-container1 {
height: 12.5em;
background: url("icons/effect-img/13.png")no-repeat;
background-size: cover;
display:block;
}
.num-container2 {
height: 12.5em;
background: url("icons/effect-img/15.png")no-repeat; background-size: cover;
display:none;
}
.num-container3 {
height: 12.5em;
background: url("icons/effect-img/177.png")no-repeat;
background-size: cover;
display:none;
}
.num-container4 {
height: 12.5em;
background: url("icons/effect-img/18.png")no-repeat;
background-size: cover;
display:none;
}
.num-container5 {
height: 12.5em;
background: url("icons/effect-img/19.png")no-repeat;
background-size: cover;
display:none;
}
.num-float{
height:1em;
margin:0 auto;
z-index: 3;
text-align:center;
margin-top: -1.35em;
}
.num-a{
background:#ffffff;
height: 0.4375em;
width: 0.4375em;
border-radius: 50%;
float: left;
opacity: 0.5;
}
.num-kong{
height: 0.625em;
width: 0.25em;
float: left;
}
.num-kong-width{
width: auto;
height: 0.9375em;
}
.num-kong-win{
height: 0.625em;
width: 0.1em;
float: left;
}
----------
<div class="num-zcon">
<div class="num-container1" id="adv1">
</div>
<div class="num-container2" id="adv2">
</div>
<div class="num-container3" id="adv3">
</div>
<div class="num-container4" id="adv4">
</div>
<div class="num-container5" id="adv5">
</div>
<div class="num-float ub ub-ac ub-pc">
<div class="num-a" id="ab1">
</div>
<div class="num-kong">
</div>
<div class="num-a" id="ab2">
</div>
<div class="num-kong">
</div>
<div class="num-a" id="ab3">
</div>
<div class="num-kong">
</div>
<div class="num-a" id="ab4">
</div>
<div class="num-kong">
</div>
<div class="num-a" id="ab5">
</div>
</div>
</div>
<script>
//橫幅廣告;
var Nownumber = 1;//1圖;
var Maxnumber = 5;//總個數(shù);
function show() {
for (var i = 1; i <= Maxnumber; i++) {
if (Nownumber == i) {
document.getElementById("adv" + Nownumber).style.display = 'block';
document.getElementById("ab" + Nownumber).style.opacity = 1;
}
else {
document.getElementById("adv" + i).style.display = 'none';
document.getElementById("ab" + i).style.opacity = 0.5;
document.getElementById("adv" + i).style.transition = "1s";
}
}
if (Nownumber == Maxnumber) {
Nownumber = 1;
}
else {
Nownumber++;
}
}
theTime = setInterval('show()', 5000);
</script>
<script>
$(document).on("pageinit","#pageone",function(){
$("#adv1").on("swiperight",function(){
$(this).hide();
Nownumber=5;
$("#adv5").show();
});
$("#adv5").on("swiperight",function(){
$(this).hide();
Nownumber=4;
$("#adv4").show();
});
$("#adv4").on("swiperight",function(){
$(this).hide();
Nownumber=3;
$("#adv3").show();
});
$("#adv3").on("swiperight",function(){
$(this).hide();
Nownumber=2;
$("#adv2").show();
});
$("#adv2").on("swiperight",function(){
$(this).hide();
Nownumber=1;
$("#adv1").show();
});
$("#adv1").on("swipeleft",function(){
$(this).hide();
Nownumber=2;
$("#adv2").show();
});
$("#adv2").on("swipeleft",function(){
$(this).hide();
Nownumber=3;
$("#adv3").show();
});
$("#adv3").on("swipeleft",function(){
$(this).hide();
Nownumber=4;
$("#adv4").show();
});
$("#adv4").on("swipeleft",function(){
$(this).hide();
Nownumber=5;
$("#adv5").show();
});
$("#adv5").on("swipeleft",function(){
$(this).hide();
Nownumber=1;
$("#adv1").show();
});
});
</script>
以上所述是小編給大家介紹的JS實現(xiàn)touch 點擊滑動輪播實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
JavaScript對象封裝的簡單實現(xiàn)方法(3種方法)
這篇文章主要介紹了JavaScript對象封裝的簡單實現(xiàn)方法,結(jié)合實例形式分析了3種簡單實現(xiàn)方法與相關(guān)注意事項,需要的朋友可以參考下2017-01-01
Typescript中將字符串轉(zhuǎn)為數(shù)值的方法小結(jié)
在TypeScript中,將字符串轉(zhuǎn)換為數(shù)值(即字符串到數(shù)字的類型轉(zhuǎn)換)有幾種方法,本文講給大家介紹幾種常見的方法,每個方法有對應(yīng)的代碼示例,需要的朋友可以參考下2023-08-08
基于Nuxt.js項目的服務(wù)端性能優(yōu)化與錯誤檢測(容錯處理)
這篇文章主要介紹了基于Nuxt.js項目的服務(wù)端性能優(yōu)化與錯誤檢測(容錯處理),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
js實現(xiàn)字符串和數(shù)組之間相互轉(zhuǎn)換操作
這篇文章主要介紹了js實現(xiàn)字符串和數(shù)組之間相互轉(zhuǎn)換操作的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-01-01
ESLint詳解及在WebStorm中的應(yīng)用步驟
ESLint是一種JavaScript代碼檢查工具,開發(fā)者可以通過自定義規(guī)則進(jìn)行代碼風(fēng)格和質(zhì)量的控制,使用ESLint的過程包括安裝、初始化配置、配置規(guī)則、運(yùn)行ESLint檢查代碼、與編輯器集成,以及與構(gòu)建工具集成等,需要的朋友可以參考下2024-09-09
javascript中的window.location.search方法簡介
window.location.search方法是截取當(dāng)前url中“?”后面的字符串,示例如下,感興趣的朋友可以參考下2013-09-09

