dimanche 23 mai 2021

addEventListener() by the second argument "function" push array value to a globally declared array and then I can't use the array at a time [duplicate]

WELL, I have globally declared an array and in second line the document.addEventListener("click",function1); inside the function1 I have inserted an array value and then I want to use the globally declared array data outside the addEventListener() function1 using if statement but the problem is that if statement dose not working at a time. I want to show a alert message by the if statement as if I can use the counterAll array in another place

var counterAll = new Array();
var f1 = document.getElementById("f1");
f2.addEventListener("click",function1);
function function1(){
    counterAll[0] = 13;
}
if(counterAll[0]===13){
alert("It work's");
}

Aucun commentaire:

Enregistrer un commentaire