3

As mentioned in the title what is the JavaScript code that replaces off in jQuery?

document.querySelector('.closeAd').off();

I tried removeEventListener but that requires parameters so won't be an option I guess.

Thanks.

  • 2
    TLDR there is no great equivalent. Do your setup properly so that you can remove events with the removeEventListener method rather than needing to rely on horribly inefficient and side-effect heavy cloning method. – Kevin B Oct 11 '21 at 18:15
  • For comparison... jQuery does it by keeping track of all event listeners you bind with jquery, allowing it to use removeEventListener efficiently. If all of your event handlers were defined functions that you could easily get a reference to, you could similarly easily remove the event listeners. – Kevin B Oct 11 '21 at 18:55

0 Answers0