JSHint and jQuery: '$' is not defined

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

The following JS:

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

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

}());

Yields:

9条回答
  •  醉梦人生
    2020-12-07 08:14

    You probably want to do the following,

    const $ = window.$
    

    to avoid it throwing linting error.

提交回复
热议问题