feature: $.on(sel, ev, fn) for persistent events
This commit is contained in:
parent
6e6341d9ad
commit
a64fd3f93c
|
@ -5,3 +5,12 @@ function $(sel, el) {
|
|||
function $$(sel, el) {
|
||||
return (el || document).querySelectorAll(sel);
|
||||
}
|
||||
|
||||
$.on = function (sel, event, fn) {
|
||||
document.body.addEventListener(function (ev) {
|
||||
if (!ev.target.matchSelector(sel)) {
|
||||
return true;
|
||||
}
|
||||
fn.call(ev.target, ev);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue