Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
create a div using javascript with its background colored randomly

1-Create an input for the person to type something and when pressing a button Create a Counter

2- A div with a colored background (randomly generate this color so that all counters are not the same)

3- The entire div must be clickable to increment the counter value

-- part 1 and 3 completed, part 2 incomplete

I would like to know if it is possible to create the divs with different colors, I implemented a random color code but it only changes the first div created and leaves the rest blank

as I couldn't post a part of the code on the site I'm leaving a link that shows the complete structure of the code

https://jsfiddle.net/8wz276rj/

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

if you're only looking for code that generates random color then

const setBg = () => {
  const randomColor = Math.floor(Math.random()*16777215).toString(16);
  document.body.style.backgroundColor = "#" + randomColor;
}

you can later set the div color through this.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda