Saturday, 2 September 2017

javascript - How to pass the index to addeventlistener in for? JS

i have a little problem with passing the index to eventlistener in for loop.



for (var i = 0; i < todos.length; i++) {

console.log("XD");
todos[i].addEventListener("mouseover", function() {
trashShow[i].style.display = "inline";
});
}


Communicate shows up that say "Cannot read property 'style' of undefined". I think that the index is just wrong so there is not this element in the array.
Thanks for help.

No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...