You need to have there anonymous function for that as you invoke alert()
function immediately in your example:
... .addEventListener('change', function() { alert('test!')}, false ...
For now according to your code addEventListener
tries to add result of undefined
(return of alert()
function).
Or you can just pass function handler for that:
function alertMe() {
alert( 'test!' );
}
...
... .addEventListener('change', alertMe, false ...
Note: that by making somefunction(arg[, arg...])
call you reference not to function, but to what function returns.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…