Date: 2009apr2
Updated: 2011jun8
Language: javaScript, php, perl
Keywords: onLoad, load, start, begin, init
Q. jQuery: Where should I initialize my stuff?
A. Use document.ready() like this:
<script>
$(document).ready(function() {
// PUT INITIALIZATION HERE
});
</script>
Or if you already have a function that you want run do init things do this:
<script>
$(document).ready(myInitFunction());
</script>
If you are using PHP:
print <<<EOF
<script>
jQuery(document).ready(function() {
// PUT INITIALIZATION HERE
});
</script>
EOF;
If you are using Perl:
print <<EOF;
<script>
jQuery(document).ready(function() {
// PUT INITIALIZATION HERE
});
</script>
EOF