Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
function resize()
{
var ht = window.innerHeight;
var h = document.getElementById("header").clientHeight;
var f = document.getElementById("footer").clientHeight;

var sum = ht-h-f;

document.getElementsByClassName("main")[0].style.height = sum+'px';

}
Posted

There's no reason to change it, if it works.

In jQuery, to get elements by ID do:
JavaScript
$("#header").height();


To get elements by class use a . instead of a #.

JavaScript
$(".main")...


There's lots of tutorials online as well if you just google the specific thing you need.
 
Share this answer
 
Try this

JavaScript
$(function () {
          alert('page load');
          var ht = window.innerHeight;
          var h = $('#header')[0].clientHeight;
          var f = $('#footer')[0].clientHeight;

          var sum = ht - h - f;
          $('.main').first().height(sum);

      });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900