Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsLint error "Cannot set property 'first' of undefined"

Run jsLint on this fiddle. The script runs, but what is jsLint telling me when it says "Problem at line 7 character 18: Cannot set property 'first' of undefined"?

Update with sample code fiddle:

(function($) {
    $.fn.selectBox = function(data) {
        for (var x = 0; x < data.length; x++) {
        }

        return this;
    };
})(jQuery);
like image 461
John Livermore Avatar asked Feb 21 '12 00:02

John Livermore


1 Answers

It's because you're defining the variable for the for statement inside of it. Declare it outside and solved!. I fixed a few other warnings. http://jsfiddle.net/SXajC/87/

like image 58
elclanrs Avatar answered Oct 12 '22 14:10

elclanrs