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

152
Visualizações
I want the color box to change dimensions as soon as soon as I input values but it is not doing so

The color is changing but the dimensions just wont change and I don't understand what's wrong with the code...

const heightBox = document.querySelector('.box-height');
const widthBox = document.querySelector('.box-width')
const input = document.querySelector('.color-input');
const colorBox = document.querySelector('.color-box');

input.addEventListener("change", function() {
  colorBox.style.backgroundColor = input.value;
  colorBox.style.height = heightBox.value + 'px';
  colorBox.style.width = widthBox.value + 'px';
});
.color-box {
  background-color: limegreen;
  width: 100px;
  height: 100px;
}
<div class="color-box"></div>
<input class="color-input" placeholder="Type a color here!" /> <br>
<input class="box-height" placeholder="Type Height Here!" /> <br>
<input placeholder="Tpye Width here!" class="box-width" />

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