pixel-editor/_ext/scripts/utilities/onChildren.js

14 lines
456 B
JavaScript
Raw Normal View History

2019-03-27 02:20:54 +03:00
//add event listener to each of specified element's children
function onChildren(event, parentElement, functionCallback) {
console.log('onChildren()');
var parentElement = (typeof parentElement == 'string' ? document.getElementById(parentElement) : parentElement);
var children = parentElement.children;
//loop through children and add onClick listener
for (var i = 0; i < children.length; i++) {
on(event, children[i],functionCallback);
}
}