Jquery-mobile-collapsible-legend

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

jQuery Mobile-折りたたみ可能な凡例

説明

_fieldset_と_legend_を使用して、フォーム要素を折りたたみ可能に表示できます。

次の例は、jQuery Mobileでfieldset_を使用して_collapsibleフォームを使用する方法を示しています。

<!DOCTYPE html>
<html>
   <head>
      <title>Collapsible Legend</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>
      <form>
         <fieldset data-role = "collapsible">
            <legend>Legend</legend>
            <label for = "text-basic">Text input:</label>
            <input type = "text" name = "text-basic" id = "text-basic"
               value = "" placeholder = "Input your text"/>

            <fieldset data-role = "controlgroup">
               <legend>Select your favourite sport</legend>
               <input type = "checkbox" name = "checkbox-1"
                  id = "checkbox-1" checked = ""/>

               <label for = "checkbox-1">Baseball</label>
               <input type = "checkbox" name = "checkbox-2" id = "checkbox-2"/>

               <label for = "checkbox-2">Cricket</label>
               <input type = "checkbox" name = "checkbox-3" id = "checkbox-3"/>

               <label for = "checkbox-3">Football</label>
               <input type = "checkbox" name = "checkbox-4" id = "checkbox-4"/>

               <label for = "checkbox-4">Hockey</label>
            </fieldset>
         </fieldset>
      </form>
   </body>
</html>

出力

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

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