Toggle three collapsible

Description

The following code shows how to toggle three collapsible.

Example


<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet"
    href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script
    src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
</head><!--   w  w  w. j  a va  2  s . com-->
<body>
  <div data-role="page">
    <div data-role="content">
      <a data-role="button" href="#">Toggle All</a>
      <div data-role="collapsible">
        <h3>Zero</h3>
        <p>Woo!</p>
      </div>
      <div data-role="collapsible" data-collapsed="false">
        <h3>One</h3>
        <p>Foo!</p>
      </div>
      <div data-role="collapsible">
        <h3>Two</h3>
        <p>Bar!</p>
      </div>
    </div>
  </div>
  <script type='text/javascript'>//<![CDATA[ 
$('a').on('click', function () {
    var $all       = $('.ui-collapsible');
    $.each($all, function () {
        if ($(this).hasClass('ui-collapsible-collapsed')) {
            $(this).trigger('expand');
        } else {
          $(this).trigger('collapse');  
        }
    });
});
//]]>  
</script>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme