首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery事件怎么传递参数

2012-08-07 
jquery事件如何传递参数function a(obj){$(#id).bind(click,function(obj){alert(obj)})}为什么不行,

jquery事件如何传递参数
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)); } 

热点排行