$ is not defined Javascript

前端 未结 3 1316
北恋
北恋 2021-02-12 23:55

I\'m writing a piece of code currently in tampermonkey and I can\'t work out why i get this error in the console of google chrome,\"Execution of script \'PalaceBOT\' failed! $ i

相关标签:
3条回答
  • 2021-02-13 00:18

    Get the jQuery from window object

    var $ = window.jQuery;
    
    0 讨论(0)
  • 2021-02-13 00:35

    You need to include JQuery $ is not part of regular javascript

    0 讨论(0)
  • 2021-02-13 00:39

    I didn't find a better answer other than this.

    In general, this chunk of code defines the library for further usage inside tampermonkey editor.

    /*globals MY_LIB*/ using this will take off all warnings.

    For more information check this (https://jshint.com/docs/#inline-configuration). It explains what globals are, and how do they work.

    0 讨论(0)
提交回复
热议问题