简体   繁体   中英

Why does JSLint say there is a missing semicolon in this jQuery?

Here are some JSLint results:

 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">&#160;</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?

You miss semicolon in line 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">&#160;</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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM