From 4b4ed5c7ed8b7a69ae95189fcee40c0509a24e63 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 5 Jan 2018 18:05:23 +0200 Subject: [PATCH] Update off.md --- snippets/off.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/off.md b/snippets/off.md index 71cbd7b3b..726dca29e 100644 --- a/snippets/off.md +++ b/snippets/off.md @@ -2,15 +2,15 @@ Removes an event listener from an element. -Use `EventTarget.removeEventListener()` to remove an event listener from an element. Omit the fourth argument `opts` to use `false` or specify it based on the options used when the event listener was added. +Use `EventTarget.removeEventListener()` to remove an event listener from an element. +Omit the fourth argument `opts` to use `false` or specify it based on the options used when the event listener was added. ```js const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); ``` ```js -// See the `on` snippet. const fn = () => console.log('!'); -const ref = on(document.body, 'click', fn, { target: 'p' }); -off(document.body, 'click', ref); // no longer logs '!' upon clicking a `p` el child of the body +document.body.addEventListener('click', fn); +off(document.body, 'click', fn); // no longer logs '!' upon clicking on the page ```