function a(obj){
$("#id").bind("click",function(obj){alert(obj);})
}
为什么不行,那应该如何传递参数呢。。才能在id对象的 click响应。。。。。
------解决方案--------------------
有点错误,重新:
- JScript code
Function.prototype.binding = function() {
if (arguments.length < 2 && typeof arguments[0] == "undefined") return this;
var __method = this, args = jQuery.makeArray(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat(jQuery.makeArray(arguments)));
}
}
function a(obj) {
$("#id").bind("click", function(obj) {
alert(obj);
}.binding(this, obj));
}