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.
})

or

(function ($) {
   $(document);
}(jQuery));
There are currently no comments.