Whilst debugging, I noticed that my script wasn't working properly. I had it structured as so:
<script>
$(document).ready(function() {
var myFunc = function() {...};
// and then some code that used myFunc()
}
</script>
But when I moved the function outside of $(document).ready()
and right before the closing script tag, and if I did a function declaration instead of a variable declaration for myFunc(), that the script worked:
<script>
$(document).ready(function() {
// and then some code that used myFunc()
}
function myFunc() {...};
</script>
Is there an order or particular structure that scripts are supposed to have?