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.');
Aucun commentaire:
Enregistrer un commentaire