Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
manually calling click() on a button, can I pass any parameters?

I am manually calling .click() on a button on a page in my jquery/javascript code.

I need to pass a parameter to click that I can then read on the function that responds to the click event.

is this possible?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You need to invoke .trigger(). You can pass over any amount of arguments there.

$('element').trigger('click', [arg1, arg2, ...]);

These extra parameters are then passed into the event handler:

$('element').bind('click', function(event, arg1, arg2, ...) {
}); 

Reference: .trigger()

over 4 years ago · Santiago Trujillo Report

0

<button id='test'>

var btn = $("button#test");
btn.attr("param", "my parameter");
btn.click();
over 4 years ago · Santiago Trujillo Report

0

No. Your onclick event is separate from your click() function. Normally, this would be possible through arguments[], but in this case you're going to have to use a variable.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!