Skip to content

Instantly share code, notes, and snippets.

@Kingdutch
Kingdutch / legacy.js
Created January 18, 2012 21:44 — forked from JeffreyWay/legacy.js
Legacy JS
// THE GOAL
// Write $('ul').on('click', 'a', fn); in JavaScript
// Must support old IE (so no Selectors API (matchesSelector) or anything)
// Can you shorten this?
var addEvent = (window.addEventListener ?
function (el, ev, fn) {
el.addEventListener(ev, fn, false);
} :
function (el, ev, fn) {