Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
removeEventListener in setInterval

I need to add new EventListener with help setInterval, but i can't remove old EventListener. getEventListeners(document) to see, that document to add "mouseup", every 100ms I not finded similar question

let tt = function() { 
   let qq = function() {  console.log(1)}
   document.removeEventListener('mouseup', qq, true); 
   document.addEventListener('mouseup', qq, true);
 }
 setInterval( tt, 100)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You redefine the qq function every time tt called, so it is a new object, and can not be matched on event listener removal process: matching event listeners for removal.

If we define function once with var, it works:

var qq = function() {  console.log(1)}

let tt = function() { 

  document.removeEventListener('mouseup', qq, true); 
  document.addEventListener('mouseup', qq, true);
}
setInterval( tt, 100)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!