jQuery Mobile - 控制组选择框

描述

使用 data-role = "controlgroup" 属性在控制组中创建下拉列表。


示例

以下示例描述了在 jQuery Mobile 框架中使用控制组选择框

<!DOCTYPE html>
<html>
   <head>
      <title>Controlgroup Selects</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>
      <h2>Vertical Select</h2>
      <form>
         <fieldset data-role = "controlgroup">
            <select>
               <option value = "#">India</option>
               <option value = "#">Australia</option>
               <option value = "#">New Zealand</option>
            </select>
         </fieldset>
      </form>
      
      <h2>Minisized Vertical Select</h2>
      <form>
         <fieldset data-role = "controlgroup" data-mini = "true">
            <select>
               <option value = "#">India</option>
               <option value = "#">Australia</option>
               <option value = "#">New Zealand</option>
            </select>
         </fieldset>
      </form>
      
      <h2>Horizontal Select</h2>
      <form>
         <fieldset data-role = "controlgroup" data-type = "horizontal">
            <select>
               <option value = "#">India</option>
               <option value = "#">Australia</option>
               <option value = "#">New Zealand</option>
            </select>
         </fieldset>
      </form>
      
      <h2>Minisized Horizontal Select</h2>
      <form>
         <fieldset data-role = "controlgroup" data-type = "horizontal" data-mini = "true">
            <select>
               <option value = "#">India</option>
               <option value = "#">Australia</option>
               <option value = "#">New Zealand</option>
            </select>
         </fieldset>
      </form>
   </body>
</html>

输出

让我们执行以下步骤,看看上面的代码是如何工作的 −

  • 将上述 html 代码保存为服务器根文件夹中的 jqm_controlgroup_selects.html 文件。

  • 将此 HTML 文件打开为 http://localhost/jqm_controlgroup_selects.html,将显示以下输出。

❮ jQuery Mobile - 小部件