jQuery innerHeight()

jQuery innerHeight() method returns the inner height of the selected element. Padding is included in this method but not the border and margin.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$(selector).innerHeight()
$(selector).innerHeight()
$(selector).innerHeight()

Example1:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
alert("Inner height of the div is: " + $("div").innerHeight());
});
});
</script>
</head>
<body>
<div style="height:100px;width:500px;padding:5px;margin:3px;border:1px solid blue;background-color:lightpink;"></div><br>
<button>Height</button>
</body>
</html>
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ alert("Inner height of the div is: " + $("div").innerHeight()); }); }); </script> </head> <body> <div style="height:100px;width:500px;padding:5px;margin:3px;border:1px solid blue;background-color:lightpink;"></div><br> <button>Height</button> </body> </html>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
alert("Inner height of the div is: " + $("div").innerHeight());
});
});
</script>
</head>
<body>
<div style="height:100px;width:500px;padding:5px;margin:3px;border:1px solid blue;background-color:lightpink;"></div><br>
<button>Height</button>
</body>
</html>

Example2:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 60px;
padding: 10px;
height: 100px;
float: left;
margin: 5px;
background: orange;
cursor: pointer;
}
.mod {
background: turquoise;
cursor: default;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>Tall</div>
<div>Small</div>
<div>Smaller</div>
<div>Smallest</div>
<script>
var modheight = 100;
$( "div" ).one( "click", function() {
$( this ).innerHeight( modheight ).addClass( "mod" );
modheight -= 10;
});
</script>
</body>
</html>
<!DOCTYPE html> <html> <head> <style> div { width: 60px; padding: 10px; height: 100px; float: left; margin: 5px; background: orange; cursor: pointer; } .mod { background: turquoise; cursor: default; } </style> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <div>Tall</div> <div>Small</div> <div>Smaller</div> <div>Smallest</div> <script> var modheight = 100; $( "div" ).one( "click", function() { $( this ).innerHeight( modheight ).addClass( "mod" ); modheight -= 10; }); </script> </body> </html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 60px;
padding: 10px;
height: 100px;
float: left;
margin: 5px;
background: orange;
cursor: pointer;
}
.mod {
background: turquoise;
cursor: default;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>Tall</div>
<div>Small</div>
<div>Smaller</div>
<div>Smallest</div>
<script>
var modheight = 100;
$( "div" ).one( "click", function() {
$( this ).innerHeight( modheight ).addClass( "mod" );
modheight -= 10;
});
</script>
</body>
</html>