- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between height and innerHeight in jQuery?
Height in jQuery
Height is the vertical measurement of the container, for example, height of a div. It excludes the padding border and margin.
To get the height of an element in jQuery, use the height() method in jQuery.
Example
You can try to run the following code to get the height:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ alert("Height of div element: " + $("div").height()); }); }); </script> </head> <body> <div style="height:300px;width:450px;padding:20px;margin:1px;border:1px solid red; background-color:gray;"></div><br> <button>Get Height of div</button> </body> </html>
innerHeight in jQuery
The innerHeight( ) method gets the inner height (excludes the border and includes the padding) for the first matched element.
Example
You can try to run the following code to learn how to work with innerHeight in jQuery:
<html> <head> <title> jQuery innerHeight()</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("div").click(function () { var color = $(this).css("background-color"); var height = $(this).innerHeight(); $("#result").html("Inner Height is <span>" + height + "</span>."); $("#result").css({'color': color, 'background-color':'gray'}); $("#result").height( height ); }); }); </script> <style> #div1{ margin:10px; padding:12px; border:2px solid #666; width:60px; } #div2 { margin:15px; padding:5px; border:5px solid #666; width:60px; } #div3 { margin:20px; padding:4px; border:4px solid #666; width:60px; } #div4 { margin:5px; padding:3px; border:3px solid #666; width:60px; } </style> </head> <body> <p>Click on any square:</p> <span id = "result"> </span> <div id = "div1" style = "background-color:blue;"></div> <div id = "div2" style = "background-color:pink;"></div> <div id = "div3" style = "background-color:#123456;"></div> <div id = "div4" style = "background-color:#f11;"></div> </body> </html>
- Related Articles
- What is the difference between innerHeight and outerHeight in jQuery?
- What is the difference between height and outerHeight in jQuery?
- What is the difference between height and line-height?
- What is the difference between jQuery and JavaScript?
- What is the difference between jQuery and AngularJS?
- What is the difference between Ajax and jQuery-Ajax methods in jQuery?
- What is the difference between event.preventDefault() and event.stopPropagation() in jQuery?
- What is the difference between text() and html() in jQuery?
- What is the difference between filter() and find() in jQuery?
- What is the difference between Grep and Filter in jQuery?
- What is the difference between jQuery.children( ) and jQuery.siblings( ) in jQuery?
- What is the difference between append() and appendTo() in jQuery?
- What is the difference between width and innerWidth in jQuery?
- What is the difference between width and outerWidth in jQuery?
- What is the difference between jQuery.offsetParent( ) and jQuery.offset( ) in jQuery?

Advertisements