jquery bind动态绑定事件传参

来源:互联网 发布:smtp默认端口号 编辑:程序博客网 时间:2024/05/17 01:18
 <span  id="s1" >

比如给span添加一个Onclick事件

$("#s1").bind("onclick",getMore);

要想传递参数应该怎么写呢

直接写

$("#s1").bind("onclick",getMore(a,b) );

这样是不对的

 

以下两种供参考
1.$(#s1").bind("onclick", {a:1,b:2},geMore(event));

 

<script>

 function getMore(event){
alert(event.data.a);

}
</script>


2.$("#s1").bind("onclick",function(){
funcionName(arg1,arg2,arg3,arg4);
});


 

原创粉丝点击