Jquery之Bind方法参数传递与接收的三种方法

来源:互联网 发布:做宣传单的软件 编辑:程序博客网 时间:2024/05/21 05:41

这篇文章主要介绍了Jquery的Bind方法参数传递与接收的三种方法,需要的朋友可以参考下:




方法一、

?
1
2
3
4
functionGetCode(event)
{
alert(event.data.foo);
}
?
1
2
3
4
$(document).ready(function()
{
$("#summary").bind("click", {foo:'abc'} ,GetCode);
});

方法二、

函数句柄

?
1
2
3
4
$("#summary").bind("click",function()
{
GetCode("abc")
});
?
1
2
3
functionGetCode(str)
{
}

方法三、

函数闭包

?
1
2
3
4
5
6
functionGetCode(str)
{
returnfunction()
{
alert(str)
}}
?
1
$("#summary").bind("click", GetCode("abc"));

0 0