Adding event listener for array of elements

This commit is contained in:
Dennis Eichhorn 2016-06-25 13:57:20 +02:00
parent 56757de774
commit ba9c02bb03

View File

@ -254,6 +254,27 @@
return null;
};
/**
* Adding event listener to multiple elements
*
* @param e DOM Elements
* @param {string} event Event name
* @param {function} callback Event callback
*
* @function
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
jsOMS.addEventListenerToAll = function(e, event, callback)
{
let length = e.length;
for(let i = 0; i < length; i++) {
e[i].addEventListener(event, callback);
}
};
/**
* Merging two arrays recursively
*