A blog on PHP, JavaScript and more Amit Merchant · July 28, 2020 · ⋆ JavaScript For instance, if you want to register a click event on an element with id checkoutBtn, you can do it like so. This will register a click event and the callback function will be called whenever the specified event is delivered to the target.
But, there might be a scenario where you might only want to invoke the click event once and after that, you no longer want to listen to the click event on the element anymore.
See the Pen Event-listener Once by Amit Merchant (@amit_merchant) on CodePen.Note that this is applicable to every event that you can register using addEventListener.» Share:Twitter, Facebook, Hacker News