之前已经问过这个问题,我搜索了每个帖子。不幸的是,它们都不适合我的情况。
我正在尝试制作一个多幻灯片旋转木马,遵循此处的编码:https://codepen.io/anon/pen/OmZppE
我在<head>
中有以下链接脚本/ CSS
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
所以我假设我正确地包含了Jquery和Bootstrap(css和js)。然而,当我执行这个脚本时
$('.multi-item-carousel').carousel({
interval: false
});
// for every slide in carousel, copy the next slide's item in the slide.
// Do the same for the next, next item.
$('.multi-item-carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
} else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
我遇到了错误:“Uncaught TypeError:$(...)。carousel不是函数”
思考?
编辑:忘记了实际轮播的HTML,忽略里面的erb代码。与问题无关。
<div class="carousel slide multi-item-carousel" id="theCarousel">
<div class="carousel-inner">
<% profile.ventures.each_with_index do |v, index| %>
<% if index == 0 %>
<div class="item active">
<% else %>
<div class="item">
<% end %>
<div class="col-xs-4">
<%= link_to v do %>
<div class="image-box">
<img src="http://placehold.it/600x450" class="thumbnail img-responsive">
<div class="image-box-caption">
<b>
<span class="image-box-text"><%= v.title %></span>
</b>
</div>
<div class="image-box-price">
<b><span class="image-box-text" style="color: white;">From $<%= v.price %></span></b>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
<a class="left carousel-control" href="#theCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#theCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
答案 0 :(得分:1)