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

179
Vistas
JS Changing CSS Height Using Variable

I have made a script that takes the height of two elements and if one is smaller than the other, will adjust the height accordingly to match. Going off the console log it is doing and recognising everything as expected except changing the elements height, which I presume is due to it being stored as a variable? Any help appreciated.

console.log('Start of script.');

let divElement = document.getElementById("basic-calendar-card");
let style = window.getComputedStyle(divElement);
let height = style.getPropertyValue("height");

console.log('Basic calendar height = ' + height);

let divElementTwo = document.getElementById("list-calendar-card");
let styleTwo = window.getComputedStyle(divElementTwo);
let heightTwo = styleTwo.getPropertyValue("height");

console.log('List calendar height = ' + heightTwo);

if (height < heightTwo) {
  console.log('List calendar is bigger.')
  divElement.style.height = heightTwo;
} else if (heightTwo < height) {
  console.log('Basic calendar is smaller.')
  divElementTwo.style.height = height;
} else {
  console.log('Same size.')
}

console.log('End of script.');
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