I have a div object with a property of width = 800. I want to assign the width of this div object to another div object.
<div id="object1" style="width: 800px;"></div>
<div id="object2"></div>
So as I'm coding on my javascript.js file, I tried to use the clientWidth method but didn't work.
var obj1 = document.getElementById("object1");
var obj2 = document.getElementById("object2");
obj2.style.width = obj1.clientWidth;
I've also tried using obj1.style.width but didn't work either. How do I change the properties of these objects by using another object's properties?
obj2.style.width = obj1.clientWidth + 'px';