jQuery + WordPress: $ is not defined

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

The following code is having some problem with the jQuery.



        
2条回答
  •  甜味超标
    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 $
    });
    

提交回复
热议问题