$ not defined using jQuery in WordPress

Posted by Prem Tiwari | Updated on

You can wrap your javascript inside a self-invoking function, then pass jQuery as an argument to it, using $ as the local variable name. For example:

If I remember correctly the WP-supplied version of jQuery (the one you get if you wp_enqueue_script(‘jquery’)) puts jQuery in no-conflict immediately, causing $ to be undefined.

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers