I’m trying to dynamically set two divs to the same max-width using javascript.. I have this so far:
window.onload = function setWidth() {
var one = document.getElementsByClassName("adsm-skin site-main");
var two = document.getElementsByClassName("pn-print-page");
style = window.getComputedStyle(one);
wdt = style.getPropertyValue("max-width");
two.style.maxWidth = wdt;
}
However it’s not working (the .pn-print-page isn’t registering having any max-width at all on page load when I’d like it to match .adsm-skin .site-main)
I’ve also tried this:
window.onload = function () {
function setWidth() {
var one = document.querySelector(".other-div");
var two = document.querySelector(".pn-print-page");
style = window.getComputedStyle(one);
wdt = style.getPropertyValue('width');
two.style.width = wdt;
}
};
No width is being added to pn-print-page either.. Is there something wrong with the code? If not do you know any other ways of doing this using javascript..? Thanks in advance