Dev-Mo
Published in : 2022-02-12
I created a script that compares the heights of two items and adjusts the heights to match if one is less than the other. According to the console log, it is doing and recognising everything as intended, with the exception of adjusting the element height, which I assume is due to the fact that it is stored as a variable? Any assistance is much appreciated.
console.log("Script Start");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("Script End");
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
nico Date : 2022-02-19
Best answers
4
Best answers
4
Hello maybe your browser is not compatible with the code.
It would be better to do this to update an attribute which will work on any main browser.
Can you test and make me know if it works better :)
Cheers