Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

97
Visualizações
How to update the same element that's in another class

I am trying to update the same element that's in another class. So currently the user_friendlist and activeusers are both are arrays of strings and it checks if both arrays contain a same entry. If that's the case then I also want to update the same element so could be [0] or [1] for both different classes.

But I don't know how to do this, I know how to do it for one class but how could I do this for the other class while checking the first one. And that's also the same element as the other one so both element0 for example but then for both different classnames.

//Display if a player is online and if he is also in the players friendlist
let friendOnlineNames        = document.getElementsByClassName('friendlistentry')
let friendlistactivitystatus = document.getElementsByClassName('friendlistactivitystatus')

const filteredArray = user_friendlist.filter(value => activeusers.includes(value));

console.log(filteredArray)

let friendNamesToString = filteredArray.toString()

console.log(friendNamesToString)

for (let i = 0; i < friendOnlineNames.length; i++) {
  if (friendOnlineNames[i].innerHTML == friendNamesToString) {
    friendlistactivitystatus[i].innerHTML = "Online"
  }
}
<h4 id="friendlisttext">Friends list
  <%= user.friendlist.length%>/20 </h4>
<div id="friendlistblock">
  <l class="friendlistentry">
    <%=user.friendlist[0]%>
  </l>
  <br/><br/>
  <form method="POST">
    <h2 class="friendlistactivitystatus"></h2>
    <input class="friendlistentryinput" name="friend0" label="friend0" type="text" value="<%=user.friendlist[0]%>">
    <button class="friendlistentrymessagebutton" formaction="friend0message">Send Message</button>
    <button class="friendlistentryprofilebutton" formaction="friend0profile">View Profile</button>
  </form>
  <l class="friendlistentry">
    <%=user.friendlist[1]%>
  </l> <br/><br/>
  <form method="POST">
    <h2 class="friendlistactivitystatus"></h2>
    <input class="friendlistentryinput" name="friend1" label="friend1" type="text" value="<%=user.friendlist[1]%>">
    <button class="friendlistentrymessagebutton" formaction="friend1message">Send Message</button>
    <button class="friendlistentryprofilebutton" formaction="friend1profile">View Profile</button>
  </form>

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda