I am trying to add eventlistener to input elements on an html with an inputListener function with a parameter as shown below. But this way does not work. I do not understand why I cannot pass the parameter to eventlistener function.
for (let index = 0; index<inputElements.length; index ++) {
inputElements[index].addEventListener("input",inputListener(index));
}
function inputListener(index){
if (inputElements[index].value.length>=5) {
inputElements[index].style.border="none";
}
else{
inputElements[index].style.border="solid 3px red";
}
}`