When I use this code inside my HTML document it\'s working:
$(\'a.tocenter[href*=#]\').click( function() {
if (location.pathname.replace(/^\\//,\'\') ==
Try adding the script tag to the bottom of your html page instead of in the header. That is done for performance reasons that way your page appears as fast as possible and the extra javascript stuff is loaded afterwards.
You can read more about this at : How does the location of a script tag in a page affect a JavaScript function that is defined in it?