由于某些原因,bootstrap不允许我在js中设置间隔时间。为什么我的javascript不会影响bootstrap旋转木马
我正在使用Middleman服务我的静态网站本地主机,我似乎无法让js影响从引导传送带。我装的引导和这样
!!!
%html
%head
%title Save Rosie
%meta{charset: "utf-8"}/
/Always force latest IE rendering engine or request Chrome Frame
%meta{content: "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible"}/
/Use title if it's in the page YAML frontmatter
= stylesheet_link_tag "fonts", "all", "bootstrap"
= javascript_include_tag "jquery-1.11.0.min", "all", "bootstrap"
%body{class: page_classes}
= yield
我的自定义JS转盘功能齐全
.carousel.slide{ "data-ride" => "carousel" }
.carousel-inner
.item.active
%img{ :src => 'https://s3-us-west-2.amazonaws.com/rosiesdonations/Rosie1.png', :alt => "Rosie Picture one" }
.item
%img{ :src => 'https://s3-us-west-2.amazonaws.com/rosiesdonations/Rosie2.jpg', :alt => "Rosie Picture two" }
.item
%img{ :src => 'https://s3-us-west-2.amazonaws.com/rosiesdonations/Rosie3.jpg', :alt => "Rosie Picture three" }
,但是当我在all.js叫
$('.carousel').carousel({
interval: 2000
})
它不会在切换2秒,而是默认值5.
看着有一个错误:Uncaught TypeError:Object [object Object] has没有方法'旋转木马'
我试着首先加载bootstrap,但没有奏效。
是DOM准备好时你设定的时间间隔? – slash197
我怎么知道? – MikaAK
您的代码必须位于'$(document).ready(function(){...您的代码...})块中;' – slash197