图片轮播使用bootstrap加上手势触摸轮播

1.引用bootstrap的js方法,但是只能实现定时图片轮播


2.添加手势触摸轮播,引用hammer.js


3.添加js代码在script中

$(function(){
var myElement=document.getElementById('Mycarousel');
var hm=new Hammer(myElement);
hm.on("swipeleft",function(){
$('#Mycarousel').carousel('next');
})
hm.on("swiperight",function(){
$('#Mycarousel').carousel('prev');
})
});

你可能感兴趣的:(原创)