
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between height and outerHeight in jQuery
height in jQuery
The 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:100px;width:350px;padding:10px;margin:10px;border:1px solid red; background-color:blue;"></div><br> <button>Get Height of div</button> </body> </html>
outerHeight() in jQuery
The outerHeight() returns the outer height of the first matched element. It includes padding and border.
Example
You can try to run the following code to get the outer height in jQuery:
<!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("Outer Height of div element: " + $("div").outerHeight()); }); }); </script> </head> <body> <div style="height:200px;width:450px;padding:10px;margin:10px;border:1px solid red; background-color:blue;"></div><br> <button>Get Outer Height of div</button> </body> </html>
Advertisements