JQuery Error – $ is not defined [Solution]
That error can only be caused by one of three things:
- Your JavaScript file is not being properly loaded into your page
- You have a botched version of jQuery. This could happen because someone edited the core file, or a plugin may have overwritten the $ variable.
- You have JavaScript running before the page is fully loaded, and as such, before jQuery is fully loaded.
- shouldn’t have attributes async or defer.
Jquery live CDN Url
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
Simple Jquery Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>If you click on me, I will disappear.</p> <p>Click me away!</p> </body> </html>