$("#foo").click(function () { alert('click event, will change the link'); this.href = "http://bit.ly/lying-links"; // optional: set the link back so it keeps working setTimeout(function () { this.href = "http://www.google.com" }, 100); });
<h2>href changing</h2> <p><a id="foo" href="http://www.google.com">link to google.com</a></p> <p>Hover over the link and watch the status bar. It should say http://www.google.com, but if you click the link you'll be sent somewhere else.</p>