National Preventative Mechanism

    on-off

    3.0.0 • Public • Published

    on-off

    Add/remove DOM events

    Install

    $ npm install on-off --save

    Usage

    var on = require('on-off')
    var off = on.off
     
    on(document.body, 'click', hello) // adds the event listener
    off(document.body, 'click', hello) // removes
     
    on(document.body.children, 'click', hello) // add to array or NodeList of elements elements
    on('a', 'click', hello) // add to multiple elements via selector
    on('a', 'click touchstart', hello) // add multiple listeners at once
     
    function hello () {
      console.log('hello!')
    }

    Related

    Changelog

    • Version 3.0.0: Added support for multiple elements, selectors, and multiple types
    • Version 1.0.0: Added test runner and removed IE8 support
    • Version 0.0.3: Republished 0.0.2
    • Version 0.0.2: Original version pre-liberation

    License

    BSD, originally developed by Azer Koçulu, maintained by Federico Brigante after v1

    Install

    npm i on-off

    DownloadsWeekly Downloads

    39

    Version

    3.0.0

    License

    BSD

    Last publish

    Collaborators

    • fregante