If you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the D
nobody mentioned this
$(function() { // place your code });
which is a shorthand function of
$(document).ready(function() { .. });