Return the inner height of a <div> element:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from w w w . j a v a 2s .co m*/ <script> $(document).ready(function(){ $("button").click(function(){ document.getElementById("demo").innerHTML = "Inner height of div: " + $("div").innerHeight(); }); }); </script> </head> <body> <p id="demo"></p> <div style="height:100px;width:300px;padding:10px;margin:3px;background-color:lightblue;"></div><br> <button>Display the inner height of div</button> <p>innerHeight() - returns the inner height of an element (includes padding).</p> </body> </html>
The innerHeight()
method returns the inner height of the first matched element.
The returned value includes padding, but not border and margin.
$(selector).innerHeight()