Home >Web Front-end >JS Tutorial >Three methods for passing and receiving parameters in Jquery's Bind method_jquery

Three methods for passing and receiving parameters in Jquery's Bind method_jquery

WBOY
WBOYOriginal
2016-05-16 16:43:201191browse

Method 1,

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

Method 2,

Function handle

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

Method 3,

Function closure

function GetCode(str)
{
return function()
{
alert(str)
}}
$("#summary").bind("click", GetCode("abc"));
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn