Advertisement
raylinanthony

DOM detecting jQ

Dec 23rd, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(window, $, undefined){
  2.  
  3.     /**
  4.      * Hooks into a given method
  5.      *
  6.      * @param method
  7.      * @param fn
  8.      */
  9.     $.fn.hook = function (method, fn) {
  10.         var def = $.fn[method];
  11.  
  12.         if (def) {
  13.             $.fn[method] = function() {
  14.                 var r = def.apply(this, arguments); //original method
  15.                 fn(this, method, arguments); //injected method
  16.                 return r;
  17.             }
  18.         }
  19.     }
  20.  
  21. })(window, jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement