为什么JSLint说这个jQuery中缺少分号?
16lz
2021-01-22
Here are some JSLint results:
以下是一些JSLint结果:
1 finaffJS.module('custom_ribbon_buttons', ['jQuery'], function ($) {
2 var my = {};
3
4 my.insertLightBoxCloseDialog = function () {
5 var url = $('#finaff-insert-lightbox-image-url').val();
6 if (url) {
7 var buttonHtml = '<a class="finaff-lightbox-link" href="' + encodeURI(url) + '"><div class="FinAff_View_Image_Button_Sprites FinAff_View_Image_Button"> </div></a>';
8 SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, buttonHtml);
9 } else {
10 $('#finaff-insert-lightbox-image-url-flash').text('Need a URL');
11 }
12 }
13
14 my.insertLightBoxClicked = function () {
=^
lint warning: missing semicolon
Where is the supposed missing semicolon?
假设丢失的分号在哪里?
Or why is JSLint confused?
或者为什么JSLint会混淆?
1 个解决方案
#1
2
You miss semicolon in line 12:
你错过第12行的分号:
4 my.insertLightBoxCloseDialog = function () {
5 var url = $('#finaff-insert-lightbox-image-url').val();
6 if (url) {
7 var buttonHtml = '<a class="finaff-lightbox-link" href="' + encodeURI(url) + '"><div class="FinAff_View_Image_Button_Sprites FinAff_View_Image_Button"> </div></a>';
8 SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, buttonHtml);
9 } else {
10 $('#finaff-insert-lightbox-image-url-flash').text('Need a URL');
11 }
12 };
Take a look at the line 2, you are declaring a variable with a {}
, and you put a semicolon. insertLightBoxCloseDialog
also needs it, is the same.
看一下第2行,你用{}声明一个变量,然后你加一个分号。 insertLightBoxCloseDialog也需要它,是一样的。
更多相关文章
- jquery done()不能获取外部变量
- 使用window.open将变量传递给新的HTML
- 如果操作已发生,则增加变量
- 如何将标记中的值传递给PHP变量?
- 你能得到一个调用类的变量吗?
- Laravel 5 PDO绑定变量数与令牌数不匹配
- 是否可以在ajax中使用动态变量?
- 在Codeigniter中将javascript变量从视图发送到控制器[重复]
- 将Ajax div内容存储在PHP变量中