简体   繁体   中英

Add -100px to jquery (body).height();

If I use (body).height(); to calculate a windows height, is there a way to calculate the height -100px.

Is there a way to do this as part of the (body).height(); query rather than calculating it later on ?

($(body).height() - 100)

只是...减去?

If you don't want to calculate it each time and deducting 100, you can define a custom function that will do it for you:

function bodyHeight() {
    return $("body").height()-100;
}

And then just call bodyHeight() instead of $("body").height() .

The fastest way would be :

var H = $(body).height() - 100 + 'px';
console.log(H);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM