Uknowho
Uknowho

Reputation: 397

Evaluating heights doesn't return right value

I am trying to handle some css via jquery when the viewport at page load doesn't include vertically some specific elements. So I'm trying to evaluate if the window's height is less than the heights of those elements combined. The problem is that this condition

var winH = parseInt($(window).height());
var topH = parseInt($("#name").height()) + parseInt($("#head-001").height());

if( winH > topH);
{
    //$("#wrapper").css("top", window.innerHeight - $("#first-bar").height()); what I want to be done if condition passes
    console.log(winH + " + " + topH + " =");
    console.log(winH + topH);
} 

always returns true... no matter if I change the evaluation to <, >, =, === it returns true despite logging the proper values and their sum as per the two lines of testing. Any idea why? Thanks.

Upvotes: 0

Views: 15

Answers (1)

Plasm
Plasm

Reputation: 109

Remove the semicolon behind the if statement:

if( winH > topH)

Upvotes: 1

Related Questions