jQuery : Error: $(document).ready is not a function — Sure!
October 19, 2008
Filed under
JavaScript
This error message appears only if another framework is in conflict with the almighty jQuery. For example You try to use Prototype/Scriptaculous for Lightbox but you also need Thickbox for something else, which requires jQuery.
Since no framework is compatible with another framework, you have to find a workaround to get things working.
And here comes jQuery in your help. The jQuery team was smart enough to realize that there will be conflicts between frameworks, especially the $ will cause massive headaches since it’s the basic of each framework. $ is the shortcut for the word “jQuery”
So, they invented jQuery.noConflict();. This will let you to replace the $ with the word jQuery, in all your code. So, when you need to call this: $(document).ready(function(){ … You simply replace the $ as I said above: jQuery(document).ready(function(){ …, don’t forget to call jQuery.noConflict(); before this.
So, when you use the noConflict() function, your code should look something like this:
<head> </head>
World saved again, now you can use 2 frameworks together.
Possible related posts (automatic):
- A social network’s UI - simple yet effective with JavaScript...
- XHTML Strict incompatible with target attribute: FALSE...
- Creating and manipulating IFrame with Javascript...
- Restrict access to directory or domain by IP, using .htaccess...
- Say bye-bye to pagead2.googlesyndication.com and then welcome (or not) googleads.g.doubleclick.net...
Related posts brought to you by Yet Another Related Posts Plugin.



















Juanlu_001 on Sat, 29th Nov 2008 11:47 am
This saved me, thank you very much!!
Thomas I on Sat, 29th Nov 2008 1:07 pm
With much pleasure Juanlu
jonycus on Mon, 1st Dec 2008 6:31 pm
I lost about a day with this problem… and guess what.. this WORKED!!! I owe you a case of beer man..
Cheers!!!
Andy Forbes on Fri, 5th Dec 2008 12:48 pm
Mirroring previous comments - wish I had found your site earlier, absolutely spot on, why cannot jquery offer this on their site more prominently.
Much Thanks, such a simple fix for a giant thorn in my side!