In this article, we will see the “Uncaught ReferenceError: $ is not a function“. The ReferenceError is an object that represents an error that arises when the variable is not initialized or simply, variable doesn’t exist in the current scope & it is referenced.
The $ sign is an alias of jQuery. The $ is not defined ReferenceError usually arises when jQuery is not loaded and JavaScript is not recognizing the $ symbol.
To solve this error, first, use jQuery CDN link inside the head section or download the jQuery file and use the jQuery file link inside the head section.
Example: This example creates a ReferenceError because jQuery is not loaded and JavaScript does not recognize the $ symbol.
HTML
|
Output:
To solve this error, we simply add the jQuery CDN link or downloaded jQuery path link inside the head section.
jQuery CDN Link:
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script>
Example: This example resolves the error by adding the required CDN link inside the <script> tag.
HTML
|
Output: