$(document).ready(function(){ Uncaught ReferenceError: $ is not defined
Solution 1
It seems you don't import jquery. Those $ functions come with this non standard (but very useful) library.
Read the tutorial there : http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery It starts with how to import the library.
Solution 2
No need to use jQuery.noConflict
and all
Try this instead:
// Replace line no. 87 (guessing from your chrome console) to the following
jQuery(document).ready(function($){
// All your code using $
});
If you still get error at line 87, like Uncaught reference error: jQuery is not defined
, then you need to include jQuery file before using it, for which you can check the above answers
Solution 3
Put this code in the <head></head>
tags:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
Solution 4
If you are sure jQuery is included try replacing $ with jQuery and try again.
Something like
jQuery(document).ready(function(){..
Still if you are getting error, you haven't included jQuery.
Solution 5
I know this is an old question, and most people have replied with good answers. But for reference and hopefully saving somebody else's time. Check if your function:
$(document).ready(function(){}
is being called after you have loaded the JQuery library
Admin
Updated on August 04, 2022Comments
-
Admin over 1 year
Hi I am having a "Uncaught ReferenceError: $ is not defined" while using bellow codes
I am currently getting the following error in my log. I have been looking at the samples in the framework and I just can't seem to find where the error is. It's been over a decade since I have done any HTML or js and what I did back then was very basic stuff. Any help would be appreciated
<script type="text/javascript"> var sQuery = '<?php echo $sQuery; ?>'; $(document).ready(function(){ if($('input[name=sPattern]').val() == sQuery) { $('input[name=sPattern]').css('color', 'gray'); } $('input[name=sPattern]').click(function(){ if($('input[name=sPattern]').val() == sQuery) { $('input[name=sPattern]').val(''); $('input[name=sPattern]').css('color', ''); } }); $('input[name=sPattern]').blur(function(){ if($('input[name=sPattern]').val() == '') { $('input[name=sPattern]').val(sQuery); $('input[name=sPattern]').css('color', 'gray'); } }); $('input[name=sPattern]').keypress(function(){ $('input[name=sPattern]').css('background',''); }) }); function doSearch() { if($('input[name=sPattern]').val() == sQuery){ return false; } if($('input[name=sPattern]').val().length < 3) { $('input[name=sPattern]').css('background', '#FFC6C6'); return false; } return true; } </script>