TypeError: $ is not a function when calling jQuery function

后端 未结 16 1819
慢半拍i
慢半拍i 2020-11-22 02:42

I have a simple jQuery script in a WordPress plugin that is using a jQuery wrapper like this:

$(document).ready(function(){

    // jQuery code is in here

}         


        
16条回答
  •  抹茶落季
    2020-11-22 02:55

    Also, I find the good solution for use jQuery noConflict mode.

    (function($){
    
      $(document).ready(function(){
          // write code here
      });
    
      // or also you can write jquery code like this
    
      jQuery(document).ready(function(){
          // write code here
      });
    
    })(jQuery);
    

    I found this solution from here. https://thecodingstuff.com/how-to-properly-use-jquery-noconflict-mode-in-wordpress/

提交回复
热议问题