If you use jQuery you know that, if you want the DOM to be ready before firing a jQuery/javascript function, you need to wrap your code in the “document ready” function like this:
$(document).ready(function() {
//some js code
});
If you prefer, you can use a shorthand:
$(function() {
//some js code
});
Enjoy!