这是我的 JavaScript:
$('#carousel-container').bind("slide.bs.carousel", function () {
//reset
$('.slideImg',this).css('min-height', '');
//set
var sliderHeight = $(this).height();
$(this).css('min-height', sliderHeight + 'px');
$(this).off("slide.bs.carousel");
//set the max size for img
$('.slideImg').css('max-height', (sliderHeight * 0.9) + 'px');
$('#Hand_Side').css('max-height', (sliderHeight * 0.4) + 'px');
});
这是我的 HTML:
<div id="carousel-container" class="carousel slide container" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div id="slide1" class="item active">
</div>
<div id="slide3" class="item">
</div>
</div>
</div>
我不确定为什么,但事件只会在滑动第一张幻灯片之前触发。
最佳答案
我看到我错过了这一行
$(this).off("slide.bs.carousel");
这一行关闭了它不应该再触发的事件
关于javascript - Bootstrap 轮播事件 'slide.bs.carousel' 仅被解雇,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32258784/