scrollHeight property in javascript
scrollHeight property is used to get the total height of the elements content, including the hidden contents due to scroll bar.
When the height is calculated it includes elements padding, but it does not include scroll bar size.
Syntax
var elem = element.scrollHeight;
Example Explanation
- In the above example, when the button is clicked fun_name() function is called.
- In the Javascript function, first we are getting the element (document.getElementById("idDiv")) and storing in attr variable.
- Using the scrollHeight property, we are getting the height of the content present inside div element, and displaying it (alert (attr.ScrollHeight)).