> This still doesn't work, I've stripped it down to this: > > $(document).click(function(e) > { > var $linkClicked = $(e.target); > if( $linkClicked.is("a") ) > { > alert("Hi"); > return false; > } > }); > > but nothing registers, the return false doesn't work and neither is there an > alert. > > Here's the relevant jquery in full: > > $(document).ready(function() > { > ////////////////////////////////////////////////////////////////// CHECK > URL > var pageHash = window.location.hash.substr(1); > > if( pageHash == "" ) // If empty open HOME > { > openPage("home"); > } > > else > { > openPage(pageHash); // Else open relevant > } > > watchLinks(); // Watch the links > pictureIt('graphics/bg/ploughedfield.jpg'); > > }); > > //////////////////////////////////////////////////////////////////// > //////////////////////////////////////////////////////////////////// WATCH > LINKS > function watchLinks() > { > $(document).click(function(e) > { > var $linkClicked = $(e.target); > if( $linkClicked.is("a") ) > { > var youWantToGoTo = > $linkClicked.attr('href').substr(0,$(this).attr('href').length-4); // > Determine destination > openPage(youWantToGoTo); // Open destination > window.location.hash = youWantToGoTo; // Set the url # > return false; > } > }); > }; > }); > };
Are you getting any errors in Firebug? Have you tried logging the event target to the Firebug console so you can see what it is? Can you post a link that shows this code running? Can you run a simple test like this: <script type="text/javascript"> $(document).click(function() { alert('test'); }); </script>