獲得函數內的參數:
[javascript] $().ready(function() {
$("#p").css( {
"border" : "1px solid red",
"height" : "300px"
});
var fn = function() {
alert(arguments[0].data.uname);
};
(function() {
$("#p").bind("click", {
"uname" : "zhangsan"
}, fn);
})();
})
模擬js的句柄:
[javascript] var fn = function() {
alert(this.prarm);
};
var obj = this;
obj.prarm = 50;
(function (){
$("#p").bind("click",{"uname":"zhangsan","this":obj},function(){
fn.call(arguments[0].data["this"],arguments[0]);
});
})();
摘自 Tender