Jquery-mobile-collapsible-markup

提供:Dev Guides
移動先:案内検索

jQuery Mobile-折りたたみ可能なマークアップ

説明

折りたたみセットは、基本的な折りたたみと同じマークアップで作成できます。 _data-role = "collapsibleset" _ 属性を追加すると、折りたたみ可能なセットになり、アコーディオンのように動作します。

次の例は、jQuery Mobileでの_collapsible set_の使用を示しています。

<!DOCTYPE html>
<html>
   <head>
      <title>Collapsible Markup</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <div data-role = "collapsibleset" data-theme = "a" data-content-theme = "a">
         <div data-role = "collapsible">
            <h3>Heading 1</h3>
            <p>Hi!! This is collapsible content for heading 1</p>
         </div>

         <div data-role = "collapsible">
            <h3>Heading 2</h3>
            <p>Hi!! This is collapsible content for heading 2</p>
         </div>

         <div data-role = "collapsible">
            <h3>Heading 3</h3>
            <p>Hi!! This is collapsible content for heading 3</p>
         </div>
      </div>
   </body>
</html>

出力

上記のコードがどのように機能するかを確認するために、次の手順を実行してみましょう-

  • 上記のhtmlコードを collapsible_markupl ファイルとしてサーバーのルートフォルダーに保存します。
  • このHTMLファイルをhttp://localhost/collapsible_markuplとして開くと、次の出力が表示されます。