does anyone know how I can create a collapsible div?

Recommended Answers

All 4 Replies

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

Hi,

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..

either with java or css

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

$('div').toggleSlide();

'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 () {
    $('div').toggleSlide();
  });
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.