未捕获的TypeError:undefined不是Wordpress中的函数(匿名函数)

Myt*_*ter 3 javascript wordpress jquery

我收到以下错误,似乎是Javascript无法解释$符号.

未捕获的TypeError:undefined不是函数main.js:1(匿名函数)main.js:1

下面附有的是main.js代码.这回事工作得很好.我试图找出指向哪里寻找问题的指针,即主题,jquery导入等.欢迎任何建议.

$(function(){ 
var cardHeight = 0;

function _setCardHeight(){

    $(".subpage-box").each( function(){ var current_height = 
    $(this).height();

        cardHeight = ( current_height > cardHeight) ? current_height : 
        cardHeight;

    }); $(".subpage-box").each( function(){ if( $(this).height() < 
    cardHeight ){ $(this).height( cardHeight );   } });


}

function _setNavStyle(){
    $("menu-main-menu > li > a").each( function(){
        var text = $(this).html();

        if( $(this).contains("for") ){

        }
    });
}

_setNavStyle();
_setCardHeight();

});
Run Code Online (Sandbox Code Playgroud)

ade*_*neo 14

默认情况下,Wordpress在noConflict模式下运行,将DOM ready包装更改为

jQuery(function($){ 

    // your code goes here

});
Run Code Online (Sandbox Code Playgroud)

否则$将是未定义的

Da Codex