set condition if height more than screen

by oktaviardi pratama

HTML

<div></div>

CSS

html, body { 0px; 100%; }

div { height: 10px;  width: 10px; background: #333;}

.red{ background: red; }

JavaScript

var div = $("div").height();
    var doc = $(window).height();

    if (div > doc ) {
        $("div").addClass('red');
    }