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

211
Views
Passing a function with an argument to addEventListener automatically runs the function onload

I'm having trouble passing a function with an arugment to an eventListener. Here's what I'm doing:

document.getElementById('Sec1_BTN1').addEventListener('click', copyS1(1));

this is the function it's referring to:

function copyS1(elemIDNum) {
    var letter_to_copy = document.getElementById('textarea-S1-' + elemIDNum);
    letter_to_copy.select();
    navigator.clipboard.writeText(letter_to_copy.value);
};

It runs the function upon load, but does not run when I click on the button that the eventListener is attached to. Any ideas of what I can do to fix it? I did some searching, but could've figure it out.

about 4 years ago · Juan Pablo Isaza
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!