国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

BootStrap實現手機端輪播圖左右滑動事件

2019-11-20 08:45:54
字體:
來源:轉載
供稿:網友

用bootstrap做出的項目輪播圖在手機端不能滑動,為此找了好多插件、框架。但是都不能和bootstrap良好的結合。

功夫不負有心人,經過一番查找終于在github找到了一段js:toucher.js,原文鏈接:https://github.com/bh-lay/toucher

由于個人水平原因代碼沒看懂抓狂,不過使用還是沒問題滴。

第一.在head中加載toucher.js。

<script type="text/JavaScript" src="__PUBLIC__/home/js/toucher.js"></script>

第二.在輪播圖頁面實現觸屏事件。

輪播圖代碼:

<div id="carousel-example-generic" class="carousel slide both" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="__PUBLIC__/home/img/banner_01.jpg" alt="..."> <div class="carousel-caption"> ... </div> </div> <div class="item"> <img src="__PUBLIC__/home/img/banner_02.jpg" alt="..."> <div class="carousel-caption"> ... </div> </div> <div class="item"> <img src="__PUBLIC__/home/img/banner_03.jpg" alt="..."> <div class="carousel-caption"> ... </div> </div> </div> <!-- Controls --> <a id="carleft" class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a id="carright" class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </div> 

js代碼:

<script> var myTouch = util.toucher(document.getElementById('carousel-example-generic')); myTouch.on('swipeLeft',function(e){ $('#carright').click(); }).on('swipeRight',function(e){ $('#carleft').click(); }); </script>

ok手機端可以用了。

以上所述是小編給大家介紹的BootStrap實現手機端輪播圖左右滑動事件,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊通| 江津市| 日土县| 三明市| 湖南省| 西安市| 台南市| 华亭县| 调兵山市| 和田市| 洪洞县| 南昌市| 望城县| 诸暨市| 公主岭市| 天水市| 九寨沟县| 两当县| 易门县| 孟州市| 鹿泉市| 广元市| 奇台县| 都昌县| 嘉黎县| 景谷| 西峡县| 庆城县| 长垣县| 宜昌市| 永胜县| 阜南县| 静安区| 沙雅县| 东安县| 蒲江县| 宁南县| 油尖旺区| 南澳县| 定远县| 双辽市|