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

142
Vistas
Trying to find a way to control background color via 11 different buttons. Question about template strings?

I have 11 buttons with their own class, as well as all 11 share the class .theme-color. I am trying to have it change to the background color on the button class. My idea was to get the class into the function and add a . to the beginning, then use the style.background to it to get the value in css.

let allThemes = document.querySelectorAll('.theme-color');
allThemes.forEach(theme => theme.addEventListener('click', themeState()));
function themeState() {
  return function (event) {
    let classFilter = event.target.classList[1];
    console.log(classFilter);
    let helpDocument = document.querySelector(`.${classFilter}`);
    console.log(helpDocument);
  };
}

Something tells me I can't do this but honestly I cannot figure out any other way. Each class has a (class).style.background = undefined even though it has it set in CSS.

Help please.

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