jQuery Mobile - 停用單選按鈕小工具



描述

在輸入元素中設定屬性 disabled = "disabled" 以停用單選按鈕。

示例

以下示例演示了在 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 Disable Example</h2>
         <fieldset data-role = "controlgroup" data-theme = "b">
            <input type = "radio" id = "radio1" name = "radio-choice-0" disabled = "disabled" />
            <label for = "radio1">Radio 1</label>

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

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

輸出

讓我們執行以下步驟,瞭解上述程式碼如何工作 -

  • 將上述的 html 程式碼儲存為 radio_disable.html 檔案,並放在伺服器根目錄的資料夾中。

  • 將此 HTML 檔案開啟為 https:///radio_disable.html 即可顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.