When I use this code inside my HTML document it\'s working:
$(\'a.tocenter[href*=#]\').click( function() { if (location.pathname.replace(/^\\//,\'\') ==
Wrap the content inside your file in
$(function(){ //js goes here });
or put the reference to the file at the bottom of your page
this allows the DOM to load before executing your script.