Home > Article > Web Front-end > Three methods for passing and receiving parameters in Jquery's Bind method_jquery
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"));