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?

2
  • 1
    Does this answer your question? adding multiple event listeners to one element Commented Feb 23, 2022 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. Commented Feb 26, 2022 at 16:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.