javascript - Is it possible to listen to all events triggered on an element -


is possible listen events triggered on dom element no matter name of event? , if possible there reason 1 should no that?

unfortunately not able find in either stackoverflow or google :(

i planning write script needs respond 2 dozens different custom events , wondering if, instead of binding each event element listen of them , based on event name, dynamically call function..

you can't in way you've suggested simple alternative:

const events = 'click mouseover mouseout';  events.split(' ').foreach(e => window.addeventlistener(e, dostuff));  function dostuff(){...} 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -