Solved

jQuery: Test if height greater than min-height

Posted on 2011-03-18
1
979 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

624 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