I am trying to select all the tags in the page and register onclick even to them.
onclick
My codes:
document.getElementsByTag
Why not use Jquery, It will be simplest solution in javascript.
You can use like below
$("a").on("click", function(event){ alert('hahahha'); });
Refer this documentation. You can use Jquery 1.7 onwards.