[英]Why does JS Fiddle give me the error `Uncaught TypeError: undefined is not a function `?
I'm testing a Plupload script when I keep getting `Uncaught TypeError: undefined is not a function . 当我不断收到`Uncaught TypeError:undefined不是一个函数时,我正在测试Plupload脚本 。
Not able to figure out why, I tested with an example from jQuery . 无法弄清原因,我使用jQuery的示例进行了测试。 I get the same error ( se fiddle ).
我收到相同的错误( se fiddle )。
Can anyone tell me why this isn't working? 谁能告诉我为什么这不起作用?
Code: 码:
$( "div" ).greenify({
color: "orange"
});
(function ( $ ) {
$.fn.greenify = function( options ) {
// Do stuff here
};
}( jQuery ));
Because you have those in the wrong order: 因为顺序错误,所以:
// First add the plugin
(function ( $ ) {
$.fn.greenify = function( options ) {
// Do stuff here
};
}( jQuery ));
// THEN use it
$( "div" ).greenify({
color: "orange"
});
The general order of things is: 事物的一般顺序是:
script
tag for jQuery script
标签 script
tags for any plugins script
标签 script
tag(s) for your code script
标签
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.