我收到以下错误,似乎是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();
});
答案 0 :(得分:14)
默认情况下,Wordpress在noConflict模式下运行,将DOM ready包装更改为
jQuery(function($){
// your code goes here
});
否则$将是未定义的