JavaScript Div Collapse Style functionality can be created by using JavaScript DOM style properties. In this sample Display property of style object of JavaScript DOM has been used to expand or collapse the DIV element dynamically.
JavaScript DOM Features Used
1. document object
2. getElementById method
3. style object
4. display property
Display property value "none" releases the white space occupied by the Div element.
Try the sample below to learn and practice the JavaScript DOM code for developing this functionality: