How to pass some parameters to function called in addEventListener? [duplicate]
You don't. Use anonymous functions:
document.getElementById('date_right').addEventListener('click', function () {
switch_date(1);
}, false);
document.getElementById('date_left').addEventListener('click', function () {
switch_date(-1);
}, false);
Or use named functions which do not take arguments:
function onRightDateClick() {
switch_date(1);
}
function onLeftDateClick() {
switch_date(-1);
}
document.getElementById('date_right').addEventListener('click', onRightDateClick, false);
document.getElementById('date_left').addEventListener('click', onLeftDateClick, false);