- jQuery Mobile 教程
- jQuery Mobile - 主頁
- jQuery Mobile - 概述
- jQuery Mobile - 安裝
- jQuery Mobile - 頁面
- jQuery Mobile - 圖示
- jQuery Mobile - 過渡
- jQuery Mobile - 佈局
- jQuery Mobile - 小控制元件
- jQuery Mobile - 事件
- jQuery Mobile - 表單
- jQuery Mobile - 主題
- jQuery Mobile - CSS 類
- jQuery Mobile - 資料屬性
- jQuery Mobile 有用資源
- jQuery Mobile - 面試問題
- jQuery Mobile - 快速指南
- jQuery Mobile - 有用資源
- jQuery Mobile - 討論
jQuery Mobile - 翻轉開關小控制元件
描述
翻轉開關允許您透過單擊布林樣式輸入來關閉/開啟或真/假開關。
示例
以下示例演示了 jQuery Mobile 中翻轉開關小控制元件的使用。
<!DOCTYPE html>
<html>
<head>
<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>
<form>
<h2>Flip Switch Examples</h2>
<h3>Basic Flipswitch</h3>
<input type = "checkbox" data-role = "flipswitch">
<h3>Basic checkbox switch with custom labels</h3>
<input type = "checkbox" data-role = "flipswitch" data-on-text = "YES"
data-off-text = "NO" data-wrapper-class = "custom-label-flipswitch" />
<h3>Basic checkbox switch with custom labels and custom size</h3>
<input type = "checkbox" data-role = "flipswitch" data-on-text = "Yes"
data-off-text = "No" data-wrapper-class = "custom-size-flipswitch" />
<h3>Basic checkbox switch checked</h3>
<input type = "checkbox" data-role = "flipswitch" checked = "" />
<h3>Basic select switch</h3>
<select data-role = "flipswitch">
<option>Off</option>
<option>On</option>
</select>
<h3>Basic select switch second option selected</h3>
<select id = "flip-select-second" name = "flip-select" data-role = "flipswitch">
<option>Off</option>
<option selected = "">On</option>
</select>
<h3>Theme</h3>
<input type = "checkbox" data-role = "flipswitch" data-theme = "b" />
<h3>Mini</h3>
<input type = "checkbox" data-role = "flipswitch" data-mini = "true" />
<h3>No corners</h3>
<input type = "checkbox" data-role = "flipswitch" data-corners = "false" />
<h3>Disabled</h3>
<input type = "checkbox" data-role = "flipswitch" disabled = "disabled" />
<h3>Label hidden</h3>
<label class = "ui-hidden-accessible">Flip toggle switch:</label>
<input type = "checkbox" data-role = "flipswitch" />
<h3>Fieldcontain</h3>
<div class = "ui-field-contain">
<label>Flip Contain:</label>
<select data-role = "flipswitch">
<option value = "off">Off</option>
<option value = "on">On</option>
</select>
</div>
<h3>Fieldcontain, mini</h3>
<div class = "ui-field-contain">
<label>Flip toggle switch:</label>
<select data-role = "flipswitch" data-mini = "true">
<option value = "off">Off</option>
<option value = "on">On</option>
</select>
</div>
</form>
</body>
</html>
輸出
我們執行以下步驟以檢視上面的程式碼如何工作 −
將以上 html 程式碼儲存在伺服器根資料夾中名為 flipswitch_basic.html 的檔案中。
將此 HTML 檔案作為 https:///flipswitch_basic.html 開啟,將顯示以下輸出。
jquery_mobile_widgets.htm
廣告