zl程序教程

您现在的位置是:首页 >  前端

当前栏目

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

jQuery方法 三种 接收 bind 参数传递
2023-06-13 09:15:32 时间

方法一、

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

方法二、

函数句柄

$("#summary").bind("click",function()
{
GetCode("abc")
});
functionGetCode(str)
{
}

方法三、

函数闭包

functionGetCode(str)
{
returnfunction()
{
alert(str)
}}
$("#summary").bind("click",GetCode("abc"));