Dustin
Dustin

Reputation: 6307

Javascript: Calculate height of DIV minus pixels

I'm currently looking for a javascript to do a math calculation for me. I'm looking for something that will read the height of an entire window (not screen size), minus 100px from that value, and then output in to, lets say, a style value. Is something like this possible?

Thanks in advance!

Upvotes: 1

Views: 6348

Answers (1)

jcarlosn
jcarlosn

Reputation: 408

To calculate the height of a div, you can use the property innerHeight, something like:

var height = document.getElementById('somediv').innerHeight;

Then, you can do the calculations you need on this variable, and use later in something like:

document.getElementById('otherdiv').style.height = height + 'px';

Upvotes: 3

Related Questions