Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chi-events

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chi-events

Easily manage DOM events

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
decreased by-40.74%
Maintainers
1
Weekly downloads
 
Created
Source

chi-events

NPM

Build Status Dependency Status

Selenium Test Status

Easily manage DOM events.

This module uses Node.js-style modules, for best results use browserify.

Example

var events = require('chi-events');

var button = document.querySelector('#myButton');

// Listening for events
events(button).on('click', function(e) {
    // Handle the event
});

// Removing listeners
var listen = events(button).on('click', function() {
    listen.remove();
});

// Listening for only one event
events(button).once('click', function() {
    // Only invoked once at most
});

// Triggering an event
// Triggers the 'click' event
events(button).trigger('click');

// Use multiple DOM nodes
events(document.querySelectorAll('a')).on('click', function(e) {
    e.preventDefault();
});

Reference

events(...nodes)

Creates a new wrapper object. nodes can be any number of nodes or arrays of nodes. Array can be infinitely nested. Also accepts psuedo-array objects, such as NodeList objects.

#on(event, handler)

Adds an event listener to all the DOM nodes. Returns an object that contains a remove function that will remove the event listener from all the nodes.

#once(event, handler)

Adds an event listener to all the DOM nodes. The handler function will be only called one time at most. The first time the event is triggered, the listener will be removed. Return value is the same as #on.

#trigger(event)

Creates an event with the event name event and dispatches the event to all the DOM nodes.

Keywords

FAQs

Package last updated on 03 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc