How to attach an event handler only once?

jQuery offers various event methods for assigning specific event listeners . Normally, jQuery methods will occur as many times as the trigger event is triggered, but when you use jQuery .one() method , the code that attached to only gets executed once per page load.
$("selector").one(event,[data],function(eventObject));
The jQuery one() method adds event handlers to the selected element. The handler is executed at most once per element per event type.
$("button").one("click", function(){ alert("Only once"); });
<button>Message show only once</button>
run this source code Browser View
Full Source
<html> <head> <title>jQuery events executed only once</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").one("click", function(){ alert("Only once"); }); }); </script> </head> <body> <button>Message show only once</button> </body> </html>