TypeError: $ is not a function when calling jQuery function

后端 未结 16 1841
慢半拍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:50

    This solution worked for me

    ;(function($){
        // your code
    })(jQuery);
    

    Move your code inside the closure and use $ instead of jQuery

    I found the above solution in https://magento.stackexchange.com/questions/33348/uncaught-typeerror-undefined-is-not-a-function-when-using-a-jquery-plugin-in-ma

    ...after searching too much

提交回复
热议问题