Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i set a height on a div using javascript

Tags:

javascript

I have a div

div id='srch'

that has a computed height of 7000px how do i set the height of the another div to the same on window.load

div id='set_me'
like image 651
Matt Elhotiby Avatar asked Apr 06 '26 05:04

Matt Elhotiby


2 Answers

document.getElementById('set_me').style.height = 
    document.getElementById('srch').offsetHeight + 'px';
like image 137
MooGoo Avatar answered Apr 08 '26 21:04

MooGoo


document.getElementById('set_me').style.height = document.getElementById('srch').offsetHeight +'px';

if the possibility of the srch height will ever change, it will always match

like image 27
Spooks Avatar answered Apr 08 '26 19:04

Spooks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!