I recently had a question. In javascript using onclick() and getElementsByClassName requires looping through all the elements. My question is if this is done enough times, can it affect performance? Is there another alternative? Thank you
ahref=document.getElementsByClassName('btnClick');
for (var i=0; i < ahref.length; i++) {
ahref[i].onclick = function(){
alert('hola');
}
};
<a href="javascript:void(0)" class="btnClick">Click1</a>
<a href="javascript:void(0)" class="btnClick">Click2</a>
<a href="javascript:void(0)" class="btnClick">Click3</a>