JSHint and jQuery: '$' is not defined

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

The following JS:

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

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

}());

Yields:

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 07:52

    To fix this error when using the online JSHint implementation:

    • Click "CONFIGURE" (top of the middle column on the page)
    • Enable "jQuery" (under the "ASSUME" section at the bottom)

提交回复
热议问题