国产探花免费观看_亚洲丰满少妇自慰呻吟_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實現手機端輪播圖左右滑動事件,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彭泽县| 景谷| 阳原县| 北宁市| 明溪县| 改则县| 岑溪市| 南华县| 江源县| 高邮市| 华容县| 石城县| 临沧市| 乐业县| 公安县| 同心县| 武山县| 北川| 西乌珠穆沁旗| 禄丰县| 武平县| 晴隆县| 瓦房店市| 房产| 成安县| 金寨县| 宜州市| 上林县| 十堰市| 安徽省| 夏邑县| 凤凰县| 茌平县| 余江县| 曲沃县| 滨州市| 汶上县| 阳山县| 五指山市| 五华县| 旬邑县|