gpt4 book ai didi

jquery - 未捕获的 TypeError : $(. ..).waterwheelCarousel 不是函数

转载 作者:行者123 更新时间:2023-12-01 01:21:40 25 4
gpt4 key购买 nike

我是 jquery 新手,我在这段代码中遇到了一些错误,你们可以识别它并纠正我的问题吗?提前致谢

这是代码。我正在尝试水车旋转木马模型,但无法查看它

<!Doctype html>
<html>
<head>
<title> this is jquery carousel</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery.waterwheelCarousel.min.js"></script>
</head>
<script>
$(document).ready(function () {
var carousel = $("#carousel").waterwheelCarousel({
flankingItems: 3,
});

$('#prev').bind('click', function () {
carousel.prev();
return false
});

$('#next').bind('click', function () {
carousel.next();
return false;
});
});
</script>
<body>


<div id="carousel">
<img src="images/1.jpg" id="item-1"/>
<img src="images/2.jpg" id="item-2"/>
<img src="images/3.jpg" id="item-3"/>
<img src="images/4.jpg" id="item-4"/>
<img src="images/5.jpg" id="item-5"/>
<img src="images/6.jpg" id="item-6"/>
</div>
<a href="#" id="prev">Prev</a>
<a href="#" id="next">Next</a>

</body>
</html>

最佳答案

1.确保有更高版本的 jQuery。

2.确保jquery.waterwheelCarousel.min.js路径正确(否则文件将不会被包含并且代码将无法工作)

工作示例:-

$(document).ready(function () {
var carousel = $("#carousel").waterwheelCarousel({
flankingItems: 3,
});

$('#prev').bind('click', function () {
carousel.prev();
return false
});

$('#next').bind('click', function () {
carousel.next();
return false;
});
});
<!Doctype html>
<html>
<head>
<title> this is jquery carousel</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/js/jquery.waterwheelCarousel.min.js"></script>
</head>
<body>
<div id="carousel">
<img src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/images/1.jpg" id="item-1"/>
<img src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/images/2.jpg" id="item-2"/>
<img src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/images/3.jpg" id="item-3"/>
<img src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/images/4.jpg" id="item-4"/>
<img src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/images/5.jpg" id="item-5"/>
<img src="https://www.jqueryscript.net/demo/jQuery-Waterwheel-Carousel-Plugin/images/6.jpg" id="item-6"/>
</div>
<a href="#" id="prev">Prev</a>
<a href="#" id="next">Next</a>

</body>
</html>

关于jquery - 未捕获的 TypeError : $(. ..).waterwheelCarousel 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47690005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com