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
Post a Comment