我與高階函數試驗在Javascript中,我寫了這樣的事情:傳遞jQuery的功能,高階函數
function hof (setter) {
setter("not test");
}
function hof2 (setter) {
setter.call(window.jQuery, "not test 2");
}
var span = $("#myTest").text;
hof(span);
hof2(span);
這裏的的jsfiddle版本:http://jsfiddle.net/6mcYt/
然而,無論是函數會拋出一個錯誤。將jQuery setter函數傳遞給更高階函數的最佳方法是什麼?
以下的答案你可能感興趣的http://stackoverflow.com/questions/18907888/how-to-wrap-the-jquery-function/18908560#18908560 – plalx