由於某些原因,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