1
我試圖使用的jCarousel和被扔在頁面加載時,它拋出這個錯誤..的JavaScript運行時錯誤而使用的jCarousel
JavaScript runtime error: Object doesn't support property or method 'jcarousel'
和我帶到了這個功能...
(function($) {
$(function() {
$('[data-jcarousel]').each(function() {
var el = $(this);
el.jcarousel(el.data());
});
$('[data-jcarousel-control]').each(function() {
var el = $(this);
el.jcarouselControl(el.data());
});
});
})(jQuery);
錯誤在第五行。
這裏是我的標記......
<div class="wrapper">
<div class="jcarousel-wrapper">
<div data-jcarousel="true" data-wrap="circular" class="jcarousel">
<ul>
<li><img src="images/1.png" width="600" height="400" alt=""></li>
<li><img src="images/2.png" width="600" height="400" alt=""></li>
<li><img src="images/3.png" width="600" height="400" alt=""></li>
<li><img src="images/4.png" width="600" height="400" alt=""></li>
</ul>
</div>
<a data-jcarousel-control="true" data-target="-=1" href="#" class="jcarousel-control-prev">‹</a>
<a data-jcarousel-control="true" data-target="+=1" href="#" class="jcarousel-control-next">›</a>
</div>
</div>
,這裏是我的頭腳本...
<meta charset="utf-8" />
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://localhost:3108/code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="jquery-1.10.2.min.js"></script>
<script src="jcarousel.data-attributes.js"></script>
我試圖只是把函數本身在頭標籤,它仍然拋出一個錯誤。我已經在這方面尋找答案,沒有具體的問題。
感謝
我很新,jquery和使用插件,當我下載jCarousel它帶有示例,當我嘗試運行我要修改的示例時,它不會運行,因爲它是說jQuery是沒有定義的。所以我試着重寫這個例子,並得到了我提到的錯誤。我只想找到一個腳本,我可以用它來做一個簡單的幻燈片顯示next和prev導航,我可以用asp.net做到這一點,但是當移動到下一個圖像時會有點搖晃。 jQuery似乎更順暢,不需要回發 – Chris
我添加了文本/ javascript類型,但它拋出了相同的錯誤。 – Chris
這不是真的問題。您需要確保包含jCarousel腳本。我會更新答案,以便更清楚。 – Josh