VinnyFonseca
11/15/2016 - 11:14 AM

addEventListener multiple events

addEventListener multiple events

['change', 'keyup', 'paste', 'input', 'propertychange', 'every_other_event_you_want'].forEach(eventType => {
  [...document.querySelectorAll('SELECTOR')].forEach(element => {
    element.addEventListener(eventType, (event) => {
      console.log(event);
      
      // Your callback here
    }, false);
  });
});