This is an example of click button to pop up an alert.
Scripts are executed in order they are encountered in the DOM1
So yes, order between scripts matters.
In this case, your script runs before jQuery does, so attempting to access $
results in a ReferenceError. To "fix" it, put your script under the jQuery script element. It doesn't matter if the scripts are in or at the bottom of the
: but the relative order of the scripts is important.
Here is a trivial mockup of the invalid ordering:
If these the order of two script elements were reversed then "foo" would be alerted, as expected.
1 (Except, perhaps, for those marked as async=true, which I will not talk about.)