I am collecting all images elements from the document var listen = document.getElementsByTagName('img');
which results in an array. Now I have to specify listen[0]
, listen[1]
, listen[2]
, listen[3]
etc to listen for events on a element from this array. The question is is there any way to just do something like listen[any item from this array]
, or a function. Just to don't have to specify every element to listen on manually.
Example
Now I have to do something like this, for every array item:
listen[3].click = function() {};