I'm trying to understand some JavaScript/jQuery code I downloaded:
<script type="text/javascript">
var messageDelay = 2000; // How long to display status messages (in milliseconds)
// Init the form once the document is ready
$( init );
// Initialize the form
function init() {
$('#contactForm').hide() // Hide the form initially
.submit( submitForm ) // on submit run submitForm() to check the inputs
.addClass( 'positioned' ); // position the form so it sits in the centre of the browser window.
// do more stuff
}
</script>
The $( init ); line is the problem. It seems to be referring to the init() function defined starting farther below, but how does it call init()? The comment line before this says we're calling init() when the DOM is ready, but there's no standard "$(function() {" to wait for the DOM.
Does anyone understand what's going on here?
Thanks