在以下情况下,我想将参数传递给 click()
处理函数:
function edit_tab(val){
var prev_tab = $("#current_tab").html();
if (prev_tab == 1) {
$('.edit-basic-info').click(a); // here I want to pass some argument "a".
}
}
如何在上面的代码中传递参数 a?我尝试做的方式不起作用。
您可以使用 trigger() 的
extraParameters
将附加参数传递给您的处理程序:
来自trigger()
文档:
extraParameters Type: Array or PlainObject Additional parameters to
pass along to the event handler.
示例(也来自文档):
$( "#foo" ).on( "custom", function( event, param1, param2 ) {
alert( param1 + "\n" + param2 );
});
$( "#foo").trigger( "custom", [ "Custom", "Event" ] );