You probably want to put this in a callback that gets triggered when the [document is ready](http://www.learningjquery.com/2006/09/introducing-document-ready).