我为样品电子商务网站创建了一个滑动产品的旋转木马,它工作正常,但它在无限循环中运行,但我想在最后一个产品到来时停止该滑块。我试过了data-wrap="false"
但它无效。请帮助我。Trying to achieve product slider present on this site
JQuery的
$('#myCarousel').carousel({
interval: 000
})
$('#myCarousel1').carousel({
interval: 000
})
$('#myCarousel2').carousel({
interval: 000
})
$('#myCarousel3').carousel({
interval: 000
})
$('#myCarousel4').carousel({
interval: 000
})
$('#myCarousel5').carousel({
interval: 000
})
$('#myCarousel6').carousel({
interval: 000
})
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
for (var i=0;i<2;i++) {
next=next.next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
HTML
<div class="carousel slide" id="myCarousel" data-ride="carousel" data-interval="000" data-pause="hover" data-wrap="false">
<div class="carousel-inner">
<div class="item active ">
<div class="col-xs-3"><a href="mobile/samsung/samsung.html"><img src="images/s8.png" class="img-responsive thumb"></a>
<h3>
Smartphones
</h3>
</div>
</div>
<div class="item">
<div class="col-xs-3"><a href="mobile/nokia/nokia.html"><img src="images/n9.jpg" class="img-responsive thumb"></a>
<h3>
Feature Phones
</h3>
</div>
</div>
<div class="item">
<div class="col-xs-3"><a href="mobile/nokia/nokia.html"><img src="images/n9.jpg" class="img-responsive thumb"></a>
<h3>
Screen Protectors
</h3>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
答案 0 :(得分:0)
试一试
$(document).ready(function() {
$('#myCarousel').carousel({
interval: 1000,
wrap: false
})
$('#myCarousel').on('slid.bs.carousel', function() {
//alert("slid");
});
$('#myCarousel').on('slid.bs.carousel', '', function() {
var $this = $(this);
$this.children('.carousel-control').show();
if($('.carousel-inner .item:first').hasClass('active')) {
$this.children('.left.carousel-control').hide();
} else if($('.carousel-inner .item:last').hasClass('active')) {
$this.children('.right.carousel-control').hide();
}
});
});