如何在自举中启用触摸幻灯片?如何在启动时通过触摸(或鼠标)在滑动条中启用滑动图像?
例如:this
,这是JS脚本:
$(document).ready(function() {
$('#myCarousel').carousel({
interval: 4000
});
var clickEvent = false;
$('#myCarousel').on('click', '.nav a', function() {
clickEvent = true;
$('.nav li').removeClass('active');
$(this).parent().addClass('active');
}).on('slid.bs.carousel', function(e) {
if(!clickEvent) {
var count = $('.nav').children().length -1;
var current = $('.nav li.active');
current.removeClass('active').next().addClass('active');
var id = parseInt(current.data('slide-to'));
if(count == id) {
$('.nav li').first().addClass('active');
}
}
clickEvent = false;
});
});
怎么能行呢?
你有什么试过?那工作?什么地方出了错?你有没有得到任何错误?你需要在你的问题中包含这些信息。请阅读本指南,以确保您的问题尽可能答案:http://stackoverflow.com/help/how-to-ask –