I have following html
HTML code for testing purposes (do not submit uncommented):
<body>
In my life, I used the following web search engines:<br/>
<a href="#test" id="mmYahooId">Yahoo!</a><br/>
<a href="#test" id="mmaltaVistaId">AltaVista</a><br/>
<a href="#test" id="mmgooId">Google</a><br/>
</body>
My JS
$('a[id^=mm]').on('click', function () {
alert("test")
var as = document.body.getElementsByTagName("a");
alert("test")
for(var i=0; i < as.length;i++) {
as[i].onClick = function(){
alert(i);
}
}
});
The alert is not giving me the index of the link clicked. How can i get the index?