0

I'm looking to reduce the following code which I'll have to repeat for multiple elements parsing different lat and lng.

var ButtonID = document.getElementById('StartButton13_06')
ButtonID.addEventListener('touchstart', function(e){Move_Map(51.858988,-3.626985)}, false);
ButtonID.addEventListener('mouseover', function(e){Move_Map(51.858988,-3.626985)}, false);
ButtonID.addEventListener('touchend', function(e){Reset_Map()}, false);
ButtonID.addEventListener('mouseout', function(e){Reset_Map()}, false);

Is it possible to add multiple eventlisteners with the same line of code when they call the same function?

Derek
  • 53
  • 8
  • 1
    Does this answer your question? [adding multiple event listeners to one element](https://stackoverflow.com/questions/11845678/adding-multiple-event-listeners-to-one-element) – pilchard Feb 23 '22 at 22:32
  • The one short suggestion, the one 174 upvotes doesn't seem to work. Maybe other understand how it is meant to be used but not me. The other suggestions are simply longer and too complicated for my needs. – Derek Feb 26 '22 at 16:12

0 Answers0