未捕获的TypeError:未定义不是Wordpress中的函数(匿名函数) [英] Uncaught TypeError: undefined is not a function (anonymous function) in Wordpress

查看:87
本文介绍了未捕获的TypeError:未定义不是Wordpress中的函数(匿名函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am getting the following error, which appears to be Javascript not interpreting the $ symbol.

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

Uncaught TypeError: undefined is not a function main.js:1 (anonymous function) main.js:1

下面附加的是main.js代码.回来的时候这个工作很好.我正在尝试找出指向哪里寻找问题的指针,即主题,jQuery导入等.欢迎提出任何建议.

Appended below is the main.js code. This was working fine sometime back. I am trying to find out pointers to where to look for the issues, i.e. theme, jquery imports, etc. Any suggestions are welcome.

$(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();

});

推荐答案

默认情况下,WordPress在noConflict模式下运行,将DOM ready wrap更改为

Wordpress is running in noConflict mode by default, change the DOM ready wrapping to

jQuery(function($){ 

    // your code goes here

});

否则$将是不确定的

Da Codex

这篇关于未捕获的TypeError:未定义不是Wordpress中的函数(匿名函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆