[email protected]

Tech Solutions

WordPress’ famous “jQuery Is Not Defined” error

This issue happens a lot! WordPress uses jQuery.noConflict(); natively. that’s why the error is common. The simplest solution is wrapping the jQuery code between:  (The code goes between the 3rd and the 5th lines)

				
					jQuery(function($){
$(document).ready(function() {

$('#elementID').css('color','red'); 

}) // document.ready end parantheses
}) // jQuery(function) end parantheses
				
			

I wanted to give the solution immediately to not waste your time! Here’s some more information about the issue:

 

WordPress is usually messy, not that WordPress has to be messy but people (even devs) can install many plugins and add custom code everywhere in an unorganized manner. By doing so, sometimes jQuery is loaded multiple times which can cause problems.

 

Our solution is not only a solution incase of a problem! It is how you should use jQuery code on WordPress for best compatibility. 

 

So, if you developed JS before and you’re confused with WordPress, this article should help you with that. You know, in the web development world, there are alot of “simple information” that are indeed simple once you know them.

 

Here, I’ll let you see the error one last time 🙂