Jquery-mobile-jqm-controlgroup-checkbox
提供:Dev Guides
jQuery Mobile-コントロールグループチェックボックス
説明
*_type = "checkbox" _* 属性を使用して、コントロールグループにチェックボックスを作成できます。
例
次の例では、jQuery Mobileフレームワークでの_controlgroup checkbox_の使用について説明します。
<!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_checkboxl ファイルとしてサーバーのルートフォルダーに保存します。
- このHTMLファイルをhttp://localhost/jqm_controlgroup_checkboxlとして開くと、次の出力が表示されます。