scrollWidth property is used to get the total width of the elements content, including the hidden contents due to scroll bar.
When the width is calculated it includes elements padding, but it does not include scroll bar size.
var elem = element.scrollWidth;
Example - Getting the scrollWidth of an element
- In the above example, when the button is clicked fun_name() function is called.
- Using the scrollWidth property, we are getting the width of the content present inside div element, and displaying it (alert (attr.scrollWidth)).