Uncaught TypeError: undefined is not a function (anonymous function) in Wordpress
10,589
Wordpress is running in noConflict mode by default, change the DOM ready wrapping to
jQuery(function($){
// your code goes here
});
otherwise $ will be undefined
Comments
-
Mythbuster almost 2 years
I am getting the following error, which appears to be Javascript not interpreting the $ symbol.
Uncaught TypeError: undefined is not a function main.js:1 (anonymous function) main.js:1
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(); });
-
Mythbuster almost 10 yearsThanks for the suggestion. Since the same functionality was working about 2 weeks ago, I can only ponder if the update for Wrodpress (3.9.1) may have led to this being broken now. Also is there a mechanism (e.g. to update the theme) to get this working as it was previously (i.e. without any changes to the code).
-
Fred Randall about 9 yearsSup, playaaaaaaaaaaaaaaaaaaa?