Adds an event listener to an element that will only run the callback the first time the event is triggered.

Use EventTarget.addEventListener() to add an event listener to an element, storing the reference in a variable.
Use a condition to call fn only the first time the listener is triggered.

继续阅读 30秒学会 JavaScript 片段 – listenOnce