0
我有這樣jQuery:我如何知道我正在使用多個回調函數調用正確的回調函數?
$.fn.myFunction = function(options, special, callback) { var settings = $.extend({ opacity : '', margin : '' }, options); //while executing this main function, some cool things happen if (special && typeof special === "function" && things_are_running) { special(); } //when finished executing the main function, there is one more thing if (callback && typeof callback === "function" && things_stopped) { callback(); } }
一個功能我真的很喜歡這個
$('.selector').myFunction(options, function() { /* this is the question about*/ });
一些有趣的東西,我怎麼能知道我打電話的special()
或callback()
功能只考慮一個回調給出?
我應該做這樣的事情?
$('.selector').myFunction(options, function() {}, null);
或這?
$('.selector').myFunction(options, null, function() {});
謝謝巴里,我會盡快測試,並讓你知道。 – thednp 2014-10-05 14:36:02