JSHint and jQuery: '$' is not defined

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

The following JS:

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

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

}());

Yields:

9条回答
  •  有刺的猬
    2020-12-07 08:09

    All you need to do is set "jquery": true in your .jshintrc.

    Per the JSHint options reference:

    jquery

    This option defines globals exposed by the jQuery JavaScript library.

提交回复
热议问题