Here’s the problem, I want two carousel with two different function in one page which mean the first carousel will be auto slide and the second carousel will be manually click but i got this problem:
-
When the first carousel slide, the second carousel will be gone.
-
When the second carousel clicked, the first carousel not responding.
So, here’s my code
$(document).ready(function() {
$('#carousel-1').carousel({
interval: 5000
});
});
$(document).ready(function() {
$('#carousel-2').carousel({
interval: false
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div id="carousel-1" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/350x150" alt="" />
</div>
<div class="item">
<img src="http://placehold.it/350x150" alt="" />
</div>
<div class="item">
<img src="http://placehold.it/350x150" alt="" />
</div>
</div>
<div class="container">
<div id="carousel-2" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/350x150" alt="" />
</div>
<div class="item">
<img src="http://placehold.it/350x150" alt="" />
</div>
<div class="item">
<img src="http://placehold.it/350x150" alt="" />
</div>
</div>
<a class="carousel-control left" href="#carousel-2" data-slide="prev">‹</a>
<a class="carousel-control right" href="#carousel-2" data-slide="next">›</a>
</div>
</div>
Here’s also my fiddle https://jsfiddle.net/za9un2wc/
I’m using Twitter Bootstrap for my work here. Any suggestion/solution can you guys give to me? Thanks
2
Answers
just add href=”#carousel-2″ in navigation of second one
You should add
</div>
before second carousel.I’m not sure it is enough for you, but looks good in my opinion.