I have some third party javascript im working with, I added some jquery code into it the javascript file. But it seems to fail on the above code when validating using Jslint
我有一些第三方javascript即时工作,我在javascript文件中添加了一些jquery代码。但是在使用Jslint进行验证时,上述代码似乎失败了
'$' was used before it was defined.
I can see at the top of the javascript file it states:
我可以在javascript文件的顶部看到它指出:
/*global alert: false, console: false, jQuery: false */
Im relatively new to Javascript, and JQuery, so any help would be welcome.
我是Javascript和JQuery的新手,所以任何帮助都会受到欢迎。
3 个解决方案
#1
74
Add these options to your comments:
将这些选项添加到您的评论中:
/*jslint browser: true*/
/*global $, jQuery, alert*/
#2
16
If you want to use variables provided by other scripts, then you need to say so:
如果要使用其他脚本提供的变量,则需要这样说:
/*global $ */
#3
2
For JSLint In Netbeans IDE go to:
对于JSLint在Netbeans IDE中,请访问:
Tools
- Options
- Miscellaneous
- JSLint tab
- Text area
under "Predefined (, separated)":
工具 - 选项 - 其他 - JSLint选项卡 - “预定义(,分隔)”下的文本区域:
- add $;
- 加$;
- add your other project global variables, separating with comma.
- 添加您的其他项目全局变量,用逗号分隔。
Now JQuery variable $ is considered defined everywhere in code.
现在JQuery变量$被认为是在代码中的任何地方定义的。
#1
74
Add these options to your comments:
将这些选项添加到您的评论中:
/*jslint browser: true*/
/*global $, jQuery, alert*/
#2
16
If you want to use variables provided by other scripts, then you need to say so:
如果要使用其他脚本提供的变量,则需要这样说:
/*global $ */
#3
2
For JSLint In Netbeans IDE go to:
对于JSLint在Netbeans IDE中,请访问:
Tools
- Options
- Miscellaneous
- JSLint tab
- Text area
under "Predefined (, separated)":
工具 - 选项 - 其他 - JSLint选项卡 - “预定义(,分隔)”下的文本区域:
- add $;
- 加$;
- add your other project global variables, separating with comma.
- 添加您的其他项目全局变量,用逗号分隔。
Now JQuery variable $ is considered defined everywhere in code.
现在JQuery变量$被认为是在代码中的任何地方定义的。