-
html/javascript
almost 10 years ago
-
over 4 years ago
ReferenceError: $ is not defined $("#calculate").click(function() { }); . . to solve this problem showing $ is not defined, all you need to do is to import jquery cdn to your index.php file because that piece is a jquery code ... you import it by going to jquery site online and copy the minifies cdn script and paste it in your index.php head.
-
-
almost 9 years ago
I would like to address some issues in your code.
The very first thing is your code seems to be using jQuery, but the jQuery library is not included on the page.
Additionally, If you check your console, you will find an error message :ReferenceError: $ is not defined $("#calculate").click(function() {
You are trying to create a custom id based selector,
var $ = function (id) { return document.getElementById(id); }
In this process you assign your function to variable "$", which is itself an object of jQuery. This assignment destroys the jquery object, Hence the above error.
For solution, check this fiddle
I suggest you to read about javascript scope and callbacks.
-
2 Answer(s)