Yashika Yashika - 1 year ago 87
HTML Question

How to change the size of parent div using JavaScript

I have on div with a table inside it. The width of div is

. I want to increase the size of my div as soon the table becomes grater than

Answer Source

If I'm understanding correctly, my take on it is below.

You could try selecting the table, then traverse the DOM tree to select .parentElement and change the width using .style


var x = document.getElementById('tableID');
x.parentElement.style.width = '200%';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download