User Tools

<HTMLElement>.off()

Removes a previously attached event callback function from an HTMLElement.

Usage:
HTMLElement = Element.off(callback)
Member of:
HTMLElement
Parameter:
callback – the previously attached function to remove again (required).
Returns:
The HTMLElement it was called on, thus allowing for command chaining.
Notes
  • This is just a simple wrapper for the JavaScript .removeEventListener method, which also allows to use more specific options.
  • The function reference needs to be the same as was previously attached using .on, or any of its shortcut functions. This implies that such a reference must be available, which by extension means that anonymous functions can not be detached.

Examples

let callback = function(e) {
  console.log(e);
}
let foo document.getElementById('foo');
foo.on('click', callback);   // attaches the callback functionfoo.off('click', callback);   // removes the function again.

See also

More information

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information