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

方法一、

 

1

2

3

4

function GetCode(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

function GetCode(str)

{

}

方法三、

函数闭包

 

1

2

3

4

5

6

function GetCode(str)

{

return function()

{

alert(str)

}}

 

1

$("#summary").bind("click", GetCode("abc"));

你可能感兴趣的:(jquery)