<a href="#" id="a1">First click</a><br/> <a href="#" id="a2">Second click</a> <script> function f() { alert(this.id); } document.body.addEventListener("click", function (event) { f.call(event.target); }); </script>