<a href="#" id="a1">First click</a>
<br/>
<a href="#" id="a2">Second click</a>
<script>
function clickMe(e) {
alert(this.id);
}
Array.apply(null, document.links).forEach(function (element) {
if (element.id == "a1" || "a2") element.onclick = clickMe;
});
</script>