document is not defined with jshint

Jeroj82 picture Jeroj82 · Nov 26, 2015 · Viewed 8k times · Source

In this code:

$scope.others=[some data...]
$scope.tab=[];
$scope.smt = function(x){
        for(var i = 0; i < $scope.others; i++){
            var el = angular.element(document.querySelector('#'+x));
            if (el.hasClass("myClass")){
                sel.push($scope.tab[i]);
            }
        }
}

JSHint complains about:

'document' is not defined

Answer

huysentruitw picture huysentruitw · Nov 26, 2015

Add "browser" : true to your jshint configuration or /* jshint browser: true */ at the top of your file to let jshint know that your environment is a browser. See documentation