Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This plugin hooks into an existing jQuery function and calls a user defined function after a jQuery function was called.
* Function hook jQuery plugin
* version 1.0
* author: Damien Antipa
(function(window, $, undefined){
* Hooks into a given method
* @param method
* @param fn
$.fn.hook = function (method, fn) {
var def = $.fn[method];
if (def) {
$.fn[method] = function() {
var r = def.apply(this, arguments); //original method
fn(this, method, arguments); //injected method
return r;
})(window, jQuery);
You can’t perform that action at this time.