开发者

"Function is not defined" - jQuery Plugins Question

开发者 https://www.devze.com 2023-03-11 01:28 出处:网络
I have a plugin in my plugins.js file that looks like this: var ShowCredits=function(){var a={addEvent:function(b,c,d,e){if(b.addEventList ...etc

I have a plugin in my plugins.js file that looks like this:

var ShowCredits=function(){var a={addEvent:function(b,c,d,e){if(b.addEventList ...etc

Over in my functions.js file I have this:

var credits = new ShowCred开发者_如何学Pythonits();
credits.code = function() { ...etc

When I lint, I get the following error message:

var credits = new ShowCredits();
'ShowCredits' is not defined.

Which makes sense because of the way the plugin is written.

Is there a way to re-write this so that the code validates?

Thanks a lot,

-Yahreen


The keyword new is to instantiate an object of the given class. Obviously, you don't define a class but a function. So just remove "new"

0

精彩评论

暂无评论...
验证码 换一张
取 消