jQuery Mobile - 控制组复选框
描述
您可以使用 type = "checkbox" 属性在控制组中创建复选框。
示例
以下示例描述了在 jQuery Mobile 框架中使用 controlgroup 控制组复选框。
<!DOCTYPE html> <html> <head> <title>Controlgroup Checkbox</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 Checkbox</h2> <form> <fieldset data-role = "controlgroup"> <input type = "checkbox" name = "checkbox1" id = "checkbox11" /> <label for = "checkbox11">India</label> <input type = "checkbox" name = "checkbox1" id = "checkbox12" /> <label for = "checkbox12">Australia</label> <input type = "checkbox" name = "checkbox1" id = "checkbox13" /> <label for = "checkbox13">New Zealand</label> </fieldset> </form> <h2>Minisized Vertical Checkbox</h2> <form> <fieldset data-role = "controlgroup" data-mini = "true"> <input type = "checkbox" name = "checkbox1" id = "checkbox14" /> <label for = "checkbox14">India</label> <input type = "checkbox" name = "checkbox1" id = "checkbox15" /> <label for = "checkbox15">Australia</label> <input type = "checkbox" name = "checkbox1" id = "checkbox16" /> <label for = "checkbox16">New Zealand</label> </fieldset> </form> <h2>Horizontal Checkbox</h2> <form> <fieldset data-role = "controlgroup" data-type = "horizontal"> <input type = "checkbox" name = "checkbox1" id = "checkbox17" /> <label for = "checkbox17">India</label> <input type = "checkbox" name = "checkbox1" id = "checkbox18" /> <label for = "checkbox18">Australia</label> <input type = "checkbox" name = "checkbox1" id = "checkbox19" /> <label for = "checkbox19">New Zealand</label> </fieldset> </form> <h2>Minisized Horizontal Checkbox</h2> <form> <fieldset data-role = "controlgroup" data-type = "horizontal" data-mini = "true"> <input type = "checkbox" name = "radio1" id = "checkbox20" /> <label for = "checkbox20">India</label> <input type = "checkbox" name = "radio1" id = "checkbox21" /> <label for = "checkbox21">Australia</label> <input type = "checkbox" name = "radio1" id = "checkbox22" /> <label for = "checkbox22">New Zealand</label> </fieldset> </form> </body> </html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 jqm_controlgroup_checkbox.html 文件。
将此 HTML 文件打开为 http://localhost/jqm_controlgroup_checkbox.html,将显示以下输出。