To calculate height sum of elements and apply as "min-height" on .body div I am using:
$(window).on("resize", function () {
var a = $("body").outerHeight();
var b = $(".header").outerHeight(true);
var c = $(".footer").outerHeight(true);
var d = $(".bottom").outerHeight(true);
$(".body").css("min-height", a - b - c - d);
}).trigger("resize");
It works fine if all elements exists on html, but if one element missing it's broken.
Good - https://jsfiddle.net/0ggr3ptv/1/
Bad - https://jsfiddle.net/oed11Lzm/1/ .bottom div is missing.
How to exclude missing elements or let them be 0?
Using jQuery 3.1.1 and .bottom div becomes undefined. How can I fix it? Thanks