NachoRuba NachoRuba - 29 days ago 10
HTML Question

Carousel slide with Swipe jQuery Bootstrap 3

i'm trying to do this with the solution of this thread:

How to make Bootstrap carousel slider use mobile left/right swipe

But dont work for me, this is my code:

<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<link href="assets/css/bootstrap.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="assets/js/jquery.mobile-1.4.5.js"></script>
<script src="assets/js/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<section class="wrap" id="month" >
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="" alt="Chania">
</div>

<div class="item">
<img src="" alt="Chania2">
</div>

<div class="item">
<img src="" alt="Flower1">
</div>

<div class="item">
<img src="" alt="Flower2">
</div>
</div>

<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>
<script src="assets/js/bootstrap.min.js"></script>
<SCRIPT>

$(document).ready(function() {
$("#myCarousel").swiperight(function() {
$("#myCarousel").carousel('prev');
});
$("#myCarousel").swipeleft(function() {
$("#myCarousel").carousel('next');
});
});
</SCRIPT>
</body>

Answer

Why don't you use slick slider instead ? it supports swipe in desktop/mobile.

Comments