Return the maximum height of a <div> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:maxHeight

Description

Return the maximum height of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {/*from   www.j  a  v  a 2s.c  o m*/
    width: 500px;
    background-color: lightblue;
    overflow: auto;
}
</style>
</head>
<body>

<button onclick="myFunction()">Test</button>

<div id="myDIV" style="max-height:100px;">
  <p>test</p>

  <p>test</p>

  <p>test</p>
</div>

<script>
function myFunction() {
    console.log(document.getElementById("myDIV").style.maxHeight);
}
</script>

</body>
</html>

Related Tutorials