jQuery + WordPress: $ is not defined

前端 未结 2 650
梦如初夏
梦如初夏 2021-01-25 23:11

The following code is having some problem with the jQuery.



        
相关标签:
2条回答
  • 2021-01-25 23:40

    Use the word jQuery instead of $ and pass it a $ reference

    jQuery(function($) {
        // you can use $ here
        $(window).load(function() {
            ..
        });
    });
    
    0 讨论(0)
  • 2021-01-25 23:48

    hey: Use jQuery with a capital Q instead of $ to make it work. Wordpress usually includes a script which calls jQuery.noConflict() at the end, leaving $ undefined.

    Okies if someone don't like this answer comment before downvote please :)

    jQuery(function($) { //jQuery passed in as first param, so you can use $ inside
       // use $
    });
    
    0 讨论(0)
提交回复
热议问题