Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
155
rated 0 times [  160] [ 5]  / answers: 1 / hits: 23643  / 9 Years ago, tue, august 11, 2015, 12:00:00

I want to pass arguments to the click() handler function in the following case:



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.
}
}


How can I pass the argument a in the above code? The way I am trying to do is not working.


More From » jquery

 Answers
2

You can use trigger()'s extraParameters to pass additional parameters to your handler:



From the trigger() documentation:




extraParameters Type: Array or PlainObject Additional parameters to
pass along to the event handler.




Example (also from the documentation):



$( #foo ).on( custom, function( event, param1, param2 ) {
alert( param1 + n + param2 );
});

$( #foo).trigger( custom, [ Custom, Event ] );

[#65452] Sunday, August 9, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucianod

Total Points: 667
Total Questions: 106
Total Answers: 92

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
lucianod questions
;