JSHint and jQuery: '$' is not defined

前端 未结 9 2115
青春惊慌失措
青春惊慌失措 2020-12-07 07:13

The following JS:

(function() {
  \"use strict\";

  $(\"#target\").click(function(){
    console.log(\"clicked\");
  });

}());

Yields:

9条回答
  •  既然无缘
    2020-12-07 08:12

    You can also add two lines to your .jshintrc

      "globals": {
        "$": false,
        "jQuery": false
      }
    

    This tells jshint that there are two global variables.

提交回复
热议问题