I am trying to get a list of buttons and add event listeners for each of it on domloaded
window.addEventListener('DOMContentLoaded', function() {
var calKeys = document.getElementById("filters").querySelectorAll("a.Button");
registerKeys(calKeys);
var registerKeys = function(inputs){
for(var i=0;i<inputs.length;i++) {
inputs[i].addEventListener("click", handleCalcKey, false);
}
};
var handleCalcKey = function(){
alert( "thi sis a test");
}
});
So my registerKeys method basically takes teh inputs and adds the handler. however it fails as uncaught type error undefined is not a function
Not sure what is going on....
registerKeysis defined after it's invoked.a.Buttonis anchors with HTMLclass='Button'. Just seeing if you knew that. Also, code is not backward compatible.