My problem is that I want to use that function for several pages, I just don't want to be placing it on all of them, <script></script>
it's very tiring.
You see, I'm starting to use Alertify.js
and I want to use this function in a separate file js
, only I get this in the browser:
ReferenceError: $ is not defined
this because I have the function like this:
$(document).ready(function() {
$("#butonanon").click(function(){
alertify.alert('hola mundo');
});
});
Image reference error:
I get like this in the Mozilla Firefox browser:
and my validationForm.js file where I have the function:
[UPDATE] SOLVED: The jquery library must be loaded before loading your js file:
Well, if you get that, it is because you are missing the JQuery library , you could solve it by adding the following line of code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Example:
Note: The version is up to you.
Make sure you have the jQuery library imported and that it is imported before your other Javascript files.
Apparently there is the problem, the js of jquery must be first so that later the others have the $ of jquery available.
According to your image, jquery is after validationForm.js
It should be roughly like this: