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

221
Vistas
How can i add style to the element in javascript?

I have this piece of code inside my javascript, I want to select the element by the class name and then be able to style it, how can I do that?

const versesHtml = `              
                ${verses.map( (v, i) => `<li class="text">${v.text_uthmani}</li> <li class="ayahNumber">{${i+1}}</li>`).join(' ')}
               
                
               
            `;

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

0

using the DOM selector and then css properties, like this:

const styling = document.querySelector('.text');
styling.style.backgroundColor = 'yellow';
styling.style.color = 'red';
about 4 years ago · Juan Pablo Isaza Denunciar

0

var elements = document.getElementsByClassName('ayahNumber'); // get all elements
    for(var i = 0; i < elements.length; i++){
        elements[i].style.backgroundColor = "black";
    }
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