I have an event handler that has 6 arguments that puts in as class name. When Im triging the function its print out all the six arguments directly,
So im trying to create an array that contains the classes, but that dont work.
The console log register that the array is calling a index value inside… but no magic on the screen.
Any ideas ?
function AddEvent(){
var AddEvent = "add";
var addClassArr= document.getElementsByClassName(AddEvent);
for(var i=0; i<addClassArr.length; i++){
var addClass = addClassArr[i];
addClass.addEventListener("click", addDiceEvent, true);
}
var diceArray = ["dice dice-side-one",
"dice dice-side-two",
"dice dice-side-three",
"dice dice-side-four",
"dice dice-side-five",
"dice dice-side-six",
"dice dice-side-six"];
function addDiceEvent() {
var sides = diceArray[2];
} }
AddEvent();
Well I can answer my question self 🙂
The problem was that I was creating the array inside the event caller.
didn’t work but this did the trick.