Jquery-mobile-form-custom-select-menus

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

jQuery Mobile-フォームのカスタム選択メニュー

説明

カスタム選択メニューを使用して、フォームにメニュー形式をポップアップ形式で表示します。

次の例は、jQuery Mobileでフォームのカスタム選択メニューを使用する方法を示しています。

<!DOCTYPE html>
<html>
   <head>
      <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 = "page">
         <div data-role = "header">
            <h2>Form Custom Select Menus</h2>
         </div>

         <div data-role = "main" class = "ui-content">
            <form method = "post" action = "jquery_mobile/demo.php">

               <fieldset class = "ui-field-contain">
                  <label for = "select-custom">Custom Select</label>
                  <select id = "select-custom" data-native-menu = "false" name = "fname">
                     <option value = "Mumbai">Mumbai</option>
                     <option value = "Pune">Pune</option>
                     <option value = "Belgaum">Belgaum</option>
                     <option value = "Chennai">Chennai</option>
                     <option value = "Bangalore">Bangalore</option>
                  </select>
               </fieldset>

               <input type = "submit" value = "Submit" data-inline = "true">
            </form>
         </div>

      </div>
   </body>
</html>

出力

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

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