on

.on(evtNames,fn)

evtNamesOne or more space-separated event types

fnA function to execute when the event is triggered

Attach an event handler function for one or more events to the element

<button id="btn">Ok</button> <script> document.querySelector("#btn").on("click", function() { alert("clicked"); }) </script>

off

.off(evtNames,fn)

evtNamesOne or more space-separated event types

fnA handler function previously attached for the event(s)

Remove an event handler.

<button id="btn">Ok</button> <button id="btn2">Off</button> <script> var fn = function() { alert("clicked"); } document.querySelector("#btn").on("click", fn); document.querySelector("#btn2").on("click", function() { document.querySelector("#btn").off("click", fn); }); </script>

trigger

.trigger(evtName, options)

evtNameA string containing a JavaScript event type, such as click or submit.

optionsAdditional parameters to pass along to the event handler.

Execute all handlers and behaviors attached to the matched elements for the given event type.

<button id="btn">Ok</button> <script> var fn = function() { alert("clicked"); } document.querySelector("#btn").on("click", fn); document.querySelector("#btn").trigger("click"); </script>