Yo.utils.removeEvent

Use this function to remove an event on the supplied DOM element using the method most appropriate for the shopper's browser.

Prerequisites

The following command to load the appropriate version of the Rapid+JS Library must precede the use of this function on the page. Specify your own site key:

<script src="https://rapid-cdn.yottaa.com/rapid/lib/sitekey.js"></script>

Syntax

Yo.utils.removeEvent(element, eventName, eventHandler);

Parameters

Parameter

Description

element

The DOM element from which to remove the event.

Example:

Yo.utils.select('#myButton')

eventName

The name of the event to remove. String. Omit the word "on".

eventHandler

The function that will be called when the event is triggered. Either the name of the function or the full code for a function.

Example

The first statement in this example declares an event handler function, onClick, that removes the 'click' event from the DOM element myButton after the user clicks the button. The following statement adds an event named 'click' to myButton and supplies the event handler onClick to register the event.

**/
* Remove event after it is used.
*/
function onClick () {
  Yo.utils.removeEvent(Yo.utils.select("#mybutton"), 'click', onClick);
}
Yo.utils.addEvent(Yo.utils.select("#mybutton"), 'click', onClick);

Yottaa registers the event handler you supply when you add an event. Yottaa uses the event handler to identify the same event when you request to remove it.