Seeking help with a div element that adjusts its size based on the elements it contains. How can I determine the final size of this dynamic div without checking the sizes of its internal elements?
I've attempted to parse all the properties of the object, but everything returned as "undefined."
Any suggestions or thoughts are greatly appreciated.
Thank you
Update:
This is my code snippet:
<div id="xxx" style="position:relative;">
aaaa
</div>
I tried accessing the width property using:
var a = mydiv.style.width;
Unfortunately, this method did not work for me.
I also attempted to display all properties by running:
var getKeys = function (obj) {
var keys = [];
for(var key in obj){
document.write(key+"="+obj.key+"<br>");
}
return keys;
}
getKeys(mydiv.style);
However, none of the properties contained any useful information.
The jQuery solution would have worked perfectly, but I'm unable to use it in this scenario. Instead, I discovered that getComputedStyle
was the resolution I needed.
Apologies for the lack of details initially provided.