Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!