JS-イベントリスナに引数を渡す
const button = document.getElementById('button');
// 無名関数内で引数を渡す
button.addEventListener('click', function(e) {
hello(e, 'Tom');
});
function hello(e, name) {
console.log(`Hello ${name}`)
}
// イベントオブジェクトを引数にもつ関数を戻り値にもつ関数をイベントハンドラに登録する
button.addEventListener('click', hey('Bob'), false);
function hey(name) {
return function(e) {
console.log(`Hey ${name}`);
}
}
input#button(type='button' value='button')