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', {