Something like that:
myLive("div", "click", function() { ... });
var liveArray = []; function myLive(selector, type, handler) { liveArray.push([selector, type, handler]); } // this handler should fire for any event on the page, and should be attached // to the document node function documentAnyEvent(e) { var e = e || window.event; var target = e.target || e.srcElement; for (var i = 0; i < liveArray.length; i++) { if (target mathes the selector AND e.type matches the type) { // fire the handler liveArray[i][2] } } }
Ε ime Vidas
source share