sam
sam

Reputation: 10094

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 ?

Upvotes: 0

Views: 1287

Answers (3)

TheZ
TheZ

Reputation: 3732

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

Just... subtract?

Upvotes: 5

Sparkup
Sparkup

Reputation: 3754

The fastest way would be :

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

Upvotes: 0

dvir
dvir

Reputation: 5115

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().

Upvotes: 0

Related Questions