Get height with and without margin - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:outerHeight

Description

Get height with and without margin

Demo Code

ResultView the demo in separate window

<!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(){
        var txt = "";
        txt += "outerHeight() of div: " + $("div").outerHeight() + "</br>";
        txt += "outerHeight(true) of div: " + $("div").outerHeight(true) + "</br>";
        $("div").html(txt);
    });//from   w w w.  ja va 2s . c o  m
});
</script>
</head>
<body>

<div style="height:120px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:red;"></div><br>

<button>Display outer height of div</button>

</body>
</html>

Related Tutorials