Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile Collapsibles

jQuery Mobile Collapsibles


Collapsible content blocks

Collapsibles allow you to hide or show content - useful for storing partial information.

To create a collapsible content block, add the data-role="collapsible" attribute to the container. Inside the container (div), add a heading element (H1-H6), followed by the HTML markup you want to expand:

Example

data-role="collapsible"

Click me - I can collapse!

I am collapsible content.

Try it »

By default, content is collapsed. To expand the content on page load, use data-collapsed="false":

Example

data-role="collapsible" data-collapsed="false"

Click me - I can collapse!

I'm now expanded by default.

Try it »


Nested collapsibles

Collapsible content blocks can be nested within each other:

Example

data-role="collapsible"

Click me - I can collapse!

I am expanded content.

data-role="collapsible"

Click me - I am a nested collapsible!

I am expanded content inside a nested collapsible.

Try it »

lamp Collapsible content blocks can be nested as many times as you need.

Collapsible sets

A collapsible set groups collapsibles together (like an accordion). When a new block is expanded, all other blocks are collapsed.

Create several collapsible content blocks, then wrap them in a new container with data-role="collapsible-set":

Example

data-role="collapsible-set"

Click me - I can collapse!

I am expanded content.

Click me - I can collapse!

I am expanded content.

Try it »


More examples

Remove rounded corners and margins with the data-inset attribute
How to remove rounded corners and margins on a collapsible.

Minimize a collapsible with the data-mini attribute
How to make a collapsible smaller.

Change icons with data-collapsed-icon and data-expanded-icon
How to change the icons of a collapsible (the default is + and -).

Using collapsibles in a popup
Create a collapsible in a popup.

Change icon position
How to change the icon position in a collapsible (the default is on the left).