function sayHello(e) { e.preventDefault(); alert("hello"); } --------------------- <a href="#" onclick="sayHello(event);">Click to say Hello</a>