JSHint and jQuery: '$' is not defined

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

The following JS:

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

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

}());

Yields:

9条回答
  •  失恋的感觉
    2020-12-07 08:04

    Here is a happy little list to put in your .jshintrc
    I will add to this list at time passes.

    {
      // other settings...
      // ENVIRONMENTS
      // "browser": true, // Is in most configs by default
      "node": true,
      // others (e.g. yui, mootools, rhino, worker, etc.)
      "globals": {
        "$":false,
        "jquery":false,
        "angular":false
        // other explicit global names to exclude
      },
    }
    

提交回复
热议问题