Tiny dependency free DOM delegator.
Use npm package manager to install the DOM delegator
npm install domd
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!');
});
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
Disable listeners from all elements using selector.
- event - javascript event
- selector - valid document query selector