i have a div-container and its top-margin should be set as a dependency of $(window).height(), so first i tried something like this:
$("div#outerstart").css("margin-top",$(window).height() -805+"px");
it worked fine, but the margin-top should never be a negative, so i tried this:
$("div#outerstart").css("margin-top",function () {
if ($(window).height() < 805) {
0+"px"
} else {
$(window).height() -805+"px"
}
});
or also
if ($(window).height() < $(document).height()) {...
but it shows no effect and margin-top is not set. do you have any suggestions?
let’s change your code to use
returnkeyword from function