[英]Javascript not including jQuery plugin?
I'm using this line of code to include a plugin by FlowPlayer.org. 我正在使用这一行代码来包含FlowPlayer.org的插件。
<script type="text/javacript" src="http://cdn.jquerytools.org/1.2.6/jquery.tools.min.js"></script>
However, it's not working; 但是,它不起作用。 the following says undefined: 以下内容表示未定义:
alert(jQuery().tooltip);
jQuery is included. jQuery 是包括在内。
Anyone have any idea why? 任何人都知道为什么?
"text/javacript"
is not a valid value for type
so the browser ignores the script. "text/javacript"
不是type
的有效值,因此浏览器将忽略脚本。 You need "text/javascript"
or better yet, just omit the type attribute entirely. 您需要"text/javascript"
或更高级的语言,只需完全省略type属性。
You must include jQuery before using plugins. 使用插件之前,您必须包含jQuery 。 Also, you must call tooltip() on some element, check demos http://flowplayer.org/tools/demos/tooltip/index.html 另外,您必须在某些元素上调用tooltip(),查看演示http://flowplayer.org/tools/demos/tooltip/index.html
You need jQuery library: 您需要jQuery库:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.2.6/jquery.tools.min.js"></script>
EDIT: And if you type alert(jQuery().tooltip());
编辑:并且如果您键入alert(jQuery().tooltip());
instead of alert(jQuery().tooltip);
而不是alert(jQuery().tooltip);
? ?
You typed javacript
on your declaration. 您在声明中键入了javacript
。 Also, tooltip is a plugin: 另外,tooltip是一个插件:
http://docs.jquery.com/Plugins/Tooltip http://docs.jquery.com/Plugins/Tooltip
Download it here: http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ 在此处下载: http : //bassistance.de/jquery-plugins/jquery-plugin-tooltip/
Anyway, a good way to check if your jQuery call is ok is to run console.log(jQuery);
无论如何,检查console是否正常的一个好方法是运行console.log(jQuery);
on your console to check if the result is valid. 在控制台上检查结果是否有效。
Also, you can use this kind of approach to prevent errors: 另外,您可以使用这种方法来防止错误:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="local/path/to/jquery-1.6.1.min.js"><\/script>')</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.