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

94
Vistas
I Read using QuerySelectall.. how to write in innerhtml of these read tags?

I have degrees in Celsius switched them to Fahrenheit and cannot write them back to page.. picked them up with this statement

temp = document.querySelectorAll(".mylist span");
        x=[]
        for (let i = 0; i < temp.length; i++) {
            temp[i].style.backgroundColor = "red";
            x[i] = Number(temp[i].innerHTML);

Cannot write them back same way... Does not work

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to set the innerHTML/textContent of the element with the new value.

const spans = document.querySelectorAll('#mylist span');

function CToF(v) {
  return v * 9/5 + 32;
}

setTimeout(() => {
  spans.forEach(span => {
    const { textContent } = span;
    span.classList.add('red');
    span.textContent = CToF(textContent);
  });
}, 2000);
.red { color: red; }
<div id="mylist">
  <span>10</span>
  <span>40</span>
  <span>90</span>
</div>

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