does anyone know how I can create a collapsible div?

What do you mean by collapsible? You mean with Javascript?


try reading this one Here. That is one of many implementation I found.

While this one Here is pretty good I think. It all depends on how fancy you want it to be..

I think this may need to be done using JS. It's quite simple to do using Jquery:


'div' can be any CSS selector. This piece of code will either collapse or open the element with a smooth animation dependent on whether it is visible or not, such as having display: none applied in your CSS. This is most useful with an event handler like 'click'.

For example, you could have a button which calls toggleSlide on the collapsable element whenever it's clicked with a few lines of code:

$(function () {
  $('button').click(function () {