Hi everyone. I'm trying to set the height of an element with jquery depending on the window height, and on the elements own position in the document. Using dimensions, I've so far come up with this: The element is a div with class .tableHolder, and I want it to get a fixed height, starting from whereever the element happens to be positioned on the page, and then take up the rest of the window except for a 20px margin on the bottom(thus the " -20")...
$(document).ready(function() { $(".tableHolder").css({ height:($(window).height()) - ($ (".tableHolder").offset().top) - 20}); $(window).resize(function() { $(".tableHolder").css({ height:($(window).height()) - ($ (".tableHolder").offset().top) - 20}); }); }); However, this only works if I have an absolute or fixed position element above this element in the DOM tree. I want the function to take the window height, and then subtract the top offset for the element from the window top regardless of what the page might contain in terms of positioned elements inbetween. The pages that this is mean for has a pretty complex buildup, so I want to skip all relations with elements other than the one in question. I'm not very good with javascript, so if anyone has any idea on how to make this work I will really appreciate it.