What is the equivalent to the below code in pure javascript?
$('.div1').height($('.div2').height());
What is the equivalent to the below code in pure javascript?
$('.div1').height($('.div2').height());
That will be the following:
document.querySelector(".div1").style.height = window.getComputedStyle(document.querySelector(".div2")).height;
Using document.getElementsByClassName
var height = document.getElementsByClassName("div1")[0].style.height;
document.getElementsByClassName("div2")[0].style.height = height;
Loop through all the elements with the class name, setting them all to the desired height. Like this:
var div1s = document.getElementsByClassName(".div1");
var height = document.getElementsByClassName(".div2")[0].height;
for (int i = 0; i < div1s.length; i++) {
div1s[i].height = height;
}