lundi 23 mars 2015

Override javascript functions


I want to override js function in this way:



var elements = {
"Element": {
name: Element,
events: ["focus","blur"]
},
"Window": {
name: Window,
events: ["scroll"]
}
}

$.each(elements, function( k, v ) {
$.each(v.events, function( i, val ) {
if (val) {
console.log(v.name.prototype[val]);

v.name.prototype[val] = function () {
return false;
}
}
});
});


Update: fixed, does anyone have suggestions how to make it better?


demo





Aucun commentaire:

Enregistrer un commentaire