我有這樣的例子:爲什麼使用這個滑塊?
$(document).ready(function() {
$('.carousel').carousel({
interval: 7000
});
});
.carousel {
z-index: -99;
}
/* keeps this behind all content */
.carousel .item {
position: fixed;
width: 100%;
height: 100%;
-webkit-transition: opacity 1s;
-moz-transition: opacity 1s;
-ms-transition: opacity 1s;
-o-transition: opacity 1s;
transition: opacity 1s;
}
.carousel .one {
background: url(assets/img/slide3blur.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .two {
background: url(assets/img/slide2blur.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .three {
background: url(assets/img/slide1blur.jpg);
background-size: cover;
-moz-background-size: cover;
}
.carousel .active.left {
left: 0;
opacity: 0;
z-index: 2;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="myCarousel" class="carousel container slide">
<div class="carousel-inner">
<div class="active item one"></div>
<div class="item two"></div>
<div class="item three"></div>
</div>
</div>
不幸的是這輪播不起作用。我收到此錯誤
Uncaught TypeError: $(...).carousel is not a function
你可以幫我解決這個錯誤嗎? 預先感謝您
如果您包含carousel.js或不包含,請檢查您的html。 – San
您必須在您的
中包含輪播,js。這就是你得到這個錯誤的原因。 –你正在使用哪個傳送帶插件,並檢查它是否包含在內 –