jQuery // var theHeight = 窗口高度减去 50px?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9916416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 11:27:25  来源:igfitidea点击:

jQuery // var theHeight = window height minus 50px?

jquerywindowheightvarpixels

提问by Ariel

I am getting the window height like this:

我得到这样的窗口高度:

var theHeight = "innerHeight" in window 
               ? window.innerHeight
               : document.documentElement.offsetHeight; 

I need a var that is theHeight minus 50px

我需要一个高度减去 50px 的变量

How do I get that?

我怎么得到它?

Thanks!

谢谢!

回答by GregL

If you are using jQuery as your tag indicates, you can just use:

如果您按照标签指示使用 jQuery,则可以使用:

var theHeight = $(window).height() - 50;

回答by Matthew Blancarte

This should do it. Just pop it on the next line.

这应该这样做。只需在下一行弹出它。

theHeight -= 50;