mirror of
https://github.com/coolaj86/ajquery.js.git
synced 2024-11-16 17:29:02 +00:00
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…
x
Reference in New Issue
Block a user