I am using while loop to attach an event in element. However event is successfully added but the function also throw error on console. if I use pre-increment then its worked fine. I just want to know what is the problem with post increment. fiddle
var elements= document.getElementsByTagName('*'), i;
i=0;
while(elements[i++]){
if(elements[i].className=='c') {
elements[i].addEventListener('click',function() {
alert(this.className)
})
}
}