Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

99
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda