Solved

jQuery: Test if height greater than min-height

Posted on 2011-03-18
1
952 Views
Last Modified: 2012-06-21
How can I test if the actual height of a div is greater than its minimum height?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<style type="text/css">

#d1, #d2 {
width: 120px;
min-height: 200px;
border: 1px solid red;
margin: 20px;
}

</style>
</head>
<body>

<div id="d1">
Hello World
</div>

<div id="d2">
Tdsafads jkadsh kdjsh jkdash kads hakdjsh adkjs hdsjk hafdsj fads jkadsh kdjsh jkdash kads hakdjsh adkjs hdsjk hafdsj fads jkadsh kdjsh jkdash kads hakdjsh adkjs hdsjk hafdsj 
Tdsafads jkadsh kdjsh jkdash kads hakdjsh adkjs hdsjk hafdsj fads jkadsh kdjsh jkdash kads hakdjsh adkjs hdsjk hafdsj fads jkadsh kdjsh jkdash kads hakdjsh adkjs hdsjk hafdsj 
</div>

<script type="text/javascript">

alert('jQuery should be used to test if the height of #d1 height is greater than its min-height')
alert('jQuery should be used to test if the height of #d2 height is greater than its min-height')

</script>

</body>
</html>

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 35166816
var d1 = $("#d1");
if ( d1.css("min-height")  < d1.css("height") )
or
if ( d1.css("min-height")  < d1.height() )
or
if ( d1.css("min-height")  < d1.innerHeight() )
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question