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>
      <form>
         <h2>Radio Theme Example</h2>
         <fieldset data-role = "controlgroup" data-theme = "b">
            <input type = "radio" id = "radio1" name = "radio-choice-0" checked = "checked" />
            <label for = "radio1">Radio 1</label>

            <input type = "radio" id = "radio2" name = "radio-choice-0" />
            <label for = "radio2">Radio 2</label>

            <input type = "radio" id = "radio3" name = "radio-choice-0" />
            <label for = "radio3">Radio 3</label>
         </fieldset>
      </form>
   </body>
</html>

輸出

執行以下步驟,檢視上面的程式碼如何工作 -

  • 將上面的 HTML 程式碼作為 radio_theme.html 檔案儲存在伺服器根資料夾中。

  • 以 https:///radio_theme.html 的形式開啟這個 HTML 檔案,將會顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.