jQuery, Tutorials, Wordpress

TypeError: ‘undefined’ is not a function (evaluating ‘$(document)’) In WordPress

04 July 2018

When we add script to WordPress Header section, sometime we get this type of errors :

TypeError: 'undefined' is not a function (evaluating '$(document)')

And In Firbug you may find this error :

$ is not a function

WordPress uses jQuery in noConflict mode by default. You need to reference it using jQuery as the variable name, not $.
Replace “jQuery(document);” in place of “$(document);”

You can easily wrap this up in a self executing function so that $ refers to jQuery again (and avoids polluting the global namespace as well), e.g.

jQuery(function($) {
  // Your code.


(function ($) {

Leave a Comments