JSLint - "jQuery" error warning

I am trying to make the following jquery JSLint code compatible.

(function ($) { "use strict"; $('.addition').click(function () { $('.textbox:last,.addition:last,.subtraction:last,.replace:last').clone(true).appendTo('.replace:last'); $('.textbox:last').val(""); $('.addition:not(:last),.subtraction:not(:last)').attr('disabled','true'); }); $('.subtraction').click(function () { if($('.replace').length === 1) { $('.subtraction').click(function (event) { event.preventDefault(); }); } else { $('.textbox:last,.addition:last,.subtraction:last,.replace:last').remove(); $('.addition:last,.subtraction:last').removeAttr('disabled'); } }); }(jQuery)); 

My code is working fine. I'm just trying to clear the JSLint warnings. I don’t understand why JSLint gives me a warning undeclared 'jQuery' in string }(jQuery)); (last line).

UPDATE
Declaring jQuery as a global variable cleared the warning.

+5
source share
2 answers

If you use jslint.com, you need to add jQuery to global variables in parameters

+8
source

If you use jslint.com, you need to replace the 1st line of your code. you need to add "global jQuery" as a comment line. Look here ..

replace: (function ($) {

using: / * global jQuery * /
jQuery (function ($) {.....

All the best.
Puspendu mondal

0
source

All Articles