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

125
Views
How to extend one javascript usage to multiple ID's

I have 13 elements, each one with a different ID. But all of them need to use one same javascript, coz this function is in common.

The problem is I don't want to create 13 identical JS for the same result. How can I make the following JS valid for each ID's?

(The ID's are called: myreply1, myreply2, myreply3, myreply4, etc. til 13)

(function(){
  const modifyElHTML = (elID, phrases) => {
  const el = document.getElementById(elID);
  let phrase;
  if (italian) {phrase = phrases.italian; }
  else if (french) {phrase = phrases.french; }
  else if (german) {phrase = phrases.german; }
  else {phrase = phrases.english; }
  el.innerHTML = `${phrase}`;  };
  modifyElHTML('myreply11', {
italian: 'Rispondi', 
french: 'Répondre', 
german: 'Antworten', 
english: 'Reply',});
})();

I tried to edit this, but it didn't work (I'm newbie, so it's sure I'm making something wrong)

  modifyElHTML('myreply1','myreply2','myreply3', {
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!