Twitter Bootstrap Carousel在加载时自动播放 [英] Twitter Bootstrap Carousel autoplay on load
问题描述
使用twitter bootstrap框架,如何将轮播调用为自动滑动。这意味着在页面加载时,轮播会自动滚动。
Using the twitter bootstrap framework, how is it possible to invoke the carousel to 'auto slide.' Meaning when the page loads, the carousel automatically scrolls.
I已尝试对下一个链接的< a>
使用javascript onLoad点击功能,但这无效。
I have tried a javascript onLoad click function for the <a>
of the next link, but this didn't work.
推荐答案
,您应作为 Twitter Bootstrap文档进行操作关于轮播,因此请设置 class = active 的第一个轮播幻灯片项,并以这种方式初始化轮播的js:
you should do as the Twitter Bootstrap Documentation says about Carousel, so set the first Carousel slide item with class="active" and initialize the js for the carousel in this way:
$(function(){
$('.carousel').carousel({
interval: 2000
});
});
然后,如果这还不够(但这从来没有发生过),请使用蛮力触发点击将鼠标悬停在轮播控制按钮,例如:
then if it's not enough (but this never happened to me) use the bruteforce triggering the click hover the carousel control buttons like this:
$(function(){
$('.carousel').carousel({
interval: 2000
});
$('.carousel-control.right').trigger('click');
});
但这只是不必要的把戏,真的,只需遵循跟风!
but this is just a not-needed trick, really, just follow the documentantion!
这篇关于Twitter Bootstrap Carousel在加载时自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!