How can I add an event for a one time click to a function?

Use modern JavaScript!

EventTarget.addEventListener("click", function() {

    // Do something cool

}, {once : true});

A Boolean indicating that the listener should be invoked at most once after being added. If true, the listener would be automatically removed when invoked.

MDN web docs

All modern browsers support this feature

Other reference

Leave a Comment