My external js file (example.js):
alert("External js file has just been loaded !");
$("#start").click(function (e) {
alert("Starting !");
});
My HTML file has <script type="text/javascript" src="example.js"></script>.
When I load the page, it alerts "External js file has just been loaded !", which means the js file is successfully loaded.
However, when I click to the Start button, it doesn't alert "Starting !".
When I insert content of example.js file to the html file, it can alert "Starting !":
<script>
alert("External js file has just been loaded !");
$("#start").click(function (e) {
alert("Starting !");
});
</script>
How can I fix such a problem with the external js file?
<script type="text/javascript" src="example.js"></script>to right before</body>.