我想重寫jQuery.find覆蓋額外的功能。我已經使用在本納德爾的博客這樣做(http://www.bennadel.com/blog/1624-Ask-Ben-Overriding-Core-jQuery-Methods.htm)討論的想法,但由於某種原因,它不爲$ .find()工作,這是我的代碼壓倒一切jQuery.find()函數來提供額外的功能
(function() {
// Store a reference to the original remove method.
var originalFindFunction = jQuery.find;
// Define overriding method.
jQuery.find = function() {
// Log that we are calling the overridden function.
Console.log("------> Find method called");
// then execute the original method
var results = originalFindFunction.apply(this, arguments);
return results;
};
})();
你有一個想法,什麼是錯的,或者我怎麼能重寫一個jquery函數?
覆蓋jquery.fn而不是解決了這個問題。感謝您的額外解釋。 – kabaros 2011-03-17 12:02:12
我不確定你要做什麼 - 所以我試圖找出兩種選擇和他們的含義:) – 2011-03-17 14:49:46