jQuery Mobile - 複選框主題



說明

使用欄位集或特定複選框輸入上的屬性 data-theme 可以將主題設定為複選框。

示例

以下示例演示了在 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>
      <h2>Checkbox Theme Example</h2>
      <form>
         <fieldset data-role = "controlgroup">
            <input type = "checkbox" id = "checkbox 1" data-theme = "b" />
            <label for = "checkbox 1">Checkbox 1</label>

            <input type = "checkbox" id = "checkbox 2" data-theme = "b" />
            <label for = "checkbox 2">Checkbox 2</label>

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

輸出

讓我們執行以下步驟來了解以上程式碼如何工作 −

  • 將以上的 html 程式碼另存為伺服器根資料夾中的 theme.html 檔案。

  • 以 https:///theme.html 開啟這個 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.