Skip to content

dmitrykuzmenkov/domd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOMD

Tiny dependency free DOM delegator.

Installation

Use npm package manager to install the DOM delegator

npm install domd

Usage

Follow the example:

<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <button class="js-button">Click me</button>
</body>
</html>
var domd = require('domd');
var d = domd(document.body);

d.on('click', '.js-button', function(ev, el) {
  console.log('Button clicked!');
});

Methods

on(event, selector, callback, use_capture)

Bind new listener to all elements.

  • event - javascript event to catch (click, keyup and etc)
  • selector - valid document query selector
  • callback - function to callback. Arguments: event, element You can return false from callback to preventDefault and stop next handler searching.
  • use_capture - use capture or not, default false

off(event, selector)

Disable listeners from all elements using selector.

  • event - javascript event
  • selector - valid document query selector