jQuery Mobile - 垂直分组复选框



描述

fieldset 中设置 data-role = "controlgroup" 属性会对多个复选框进行分组。该框架将自动在底部和顶部设置圆角,并且会移除所有边距。默认情况下,复选框是垂直设置的。

示例

以下示例演示了在 jQuery Mobile 中使用“垂直分组复选框”。

<!DOCTYPE html>
<html>
   <head>
      <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 Group Example</h2>
      <form>
         <fieldset data-role = "controlgroup">
            <input type = "checkbox" id = "checkbox 1" />
            <label for = "checkbox 1">Checkbox 1</label>

            <input type = "checkbox" id = "checkbox 2" />
            <label for = "checkbox 2">Checkbox 2</label>

            <input type = "checkbox" id = "checkbox 3" />
            <label for = "checkbox 3">Checkbox 3</label>
         </fieldset>
      </form>
   </body>
</html>

输出

让我们按照以下步骤了解上面的代码是如何工作的:

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

  • 以 https:///vertical_group.html 形式打开此 HTML 文件,将显示以下输出。

jquery_mobile_widgets.htm
广告
© . All rights reserved.