Use delegation with .on()
$('body')on('click','a[href="gohere.html"]',function() {
alert("clicked!"); //should display the message, but doesn't
});
replacing 'body'
(Not necessary but more efficient) with the closest ancestor that is static and exists at the time of dom ready. This will bind the event handler to that element - which in turn listens for the event as it bubbles up from the given selector.