0

I want to start a function when I over mouse an ID #show-details. But I need it to start only one until it ends, not to start over and over again ...

With my code below It starts when I mouseover it but starts over and over even if it doesn't finish. I need some help :)

function showDetails() {

  var details = document.getElementById('show-details');

  details.addEventListener('mouseover', initDetailsLetters);

} 
Penny Liu
  • 11,885
  • 5
  • 66
  • 81
Lo1176
  • 31
  • 5
  • Please provide a [minimal, reproducible example](/help/minimal-reproducible-example). – D. Pardal Jun 02 '20 at 14:10
  • Does this answer your question? [force javascript EventListener to execute once?](https://stackoverflow.com/questions/4878805/force-javascript-eventlistener-to-execute-once) – Mark Baijens Jun 02 '20 at 14:12

2 Answers2

0

i think you need a flag, if the flag doesnt exist then create it and start over, if it does exist then dont run the code

0

Try a callback function, I have found this example to help you: Proper way to wait for one function to finish before continuing?

This looks similar to your problem

Dannick Bédard
  • 346
  • 4
  • 11