jQuery(“#mycarousel”).jcarousel 不是函数
我一定在这里做了一些非常愚蠢的事情,但我已经绞尽脑汁了一段时间了,但我无法找到问题所在。
在此页面上: http://ww2.accudata.com/
我正在尝试实现 jCarousel,但不断收到此错误:
jQuery("#mycarousel").jcarousel 不是函数
这是我的标题中的内容:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js?ver=1.6.4"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/js/skins/carousel/skin.css" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
});
});
</script>
据我所知,我正在以正确的顺序加载所有脚本,并且我已经验证它们都是那里。那么为什么说它不是一个函数呢?
I must be doing something really stupid here, but I've been beating my head against it for a while and I haven't been able to find what's wrong.
On this page:
http://ww2.accudata.com/
I'm trying to implement jCarousel, and I keep getting this error:
jQuery("#mycarousel").jcarousel is not a function
Here's what I have in my header:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js?ver=1.6.4"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/js/skins/carousel/skin.css" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
});
});
</script>
So as far as I can tell, I'm loading all of the scripts in the correct order, and I have verified that they are all there. So why does it say it's not a function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在第 39 行,您将重新加载 jQuery,这会覆盖 jQuery 对象,从而删除
.jcarousel
函数。确保您仅加载 jQuery 一次。On line 39, you are reloading jQuery, which overwrites the jQuery object, removing the
.jcarousel
function. Make sure you are loading jQuery only once.您看到的错误基本上意味着:
打开页面源代码并查看正在呈现的 HTML。 .js 文件的路径是否正确且符合您的预期?大多数时候,这是导致此类问题的原因。
因此,一旦您确定对 .js 文件的引用正确,请尝试如下操作:
The error you're seeing basically means:
Open the page source and see what HTML is being rendered. Are you paths to the .js files correct and what you expect? Most of the times this is the cause of these types of problems.
So once you're sure that your references to the .js files are correct, try something like this:
您收到
jcarousel
函数未知的错误,这意味着带有jcarousel
函数的js
文件未正确加载。 (对JQuery
本身的引用有效,因为jQuery(document).ready...
没有给您错误)查看渲染的 HTML 并查看路径是否使文件与他的实际位置相匹配。 (他们不是...)
顺便说一句,你为什么不使用 JQuery 别名
$
?jQuery('#mycarousel')
=>;$('#mycarousel')
JQuery 口号是“少写多做”
You get an error that
jcarousel
function is unknown which means that thejs
file with thejcarousel
function was not loaded correctly. (The reference toJQuery
itself works because thejQuery(document).ready...
didn't give you an error)Look at the rendered HTML and see if the path to the file match to his actual location. (They are not...)
By the way, why aren't you using JQuery alias
$
?jQuery('#mycarousel')
=>$('#mycarousel')
JQuery slogan is "Write less do more"