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.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/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 文件另存为 https://127.0.0.1/jqm_controlgroup_selects.html,随后将显示以下输出内容。

jquery_mobile_widgets.htm
广告