當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


jQuery UI Buttonset disabled用法及代碼示例

jQuery UI 由 GUI 小部件、視覺效果和使用 HTML、CSS 和 jQuery 實現的主題組成。 jQuery UI 非常適合為網頁構建 UI 接口。 jQuery UI 按鈕集小部件用於為一組相關按鈕提供視覺分組。

jQuery UI buttonset disabled 選項用於禁用或啟用指定的buttonset 小部件。此選項接受布爾值。

用法:用於使用禁用選項初始化按鈕集。

$( ".selector" ).buttonset({
 disabled:true
});
  • 將禁用選項設置為真值。

    $( ".selector" ).buttonset( "option", "disabled", true );
  • 獲取禁用選項的值。

    var disabled = $( ".selector" ).buttonset( "option", "disabled" );

CDN鏈接:首先,添加項目所需的jQuery UI腳本。

<link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css”>
<script src=”//code.jquery.com/jquery-1.12.4.js”></script>
<script src=”//code.jquery.com/ui/1.12.1/jquery-ui.js”></script>

例:此示例演示了 jQuery UI 按鈕集禁用選項。

HTML


<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
    <script src=
"//code.jquery.com/jquery-1.12.4.js">
    </script>
    <script src=
"//code.jquery.com/ui/1.12.1/jquery-ui.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
        <h3>jQuery UI Buttonset disabled Option</h3>
        <form>
            <fieldset>
                <legend>Button_Set</legend>
                <div id="ButtonSet_Radio">
                    <input id="Company" type="radio" 
                           checked="checked">
                    <label for="Company">GeeksforGeeks</label>
                    <input id="Department" type="radio">
                    <label for="Department">Computer Science</label>
                </div>
            </fieldset>
        </form>
        <input type="button" id="Button_for_disabled" 
               style="padding:5px 15px; margin-top:40px;"
               value="Value of the disabled option">
        <div id="log"></div>
    </center>
    <script>
        $(document).ready(function () {
            $("#ButtonSet_Radio").buttonset({
                disabled:true
            });
            $("#ButtonSet_Radio").buttonset("option", "disabled", true);
            $("#Button_for_disabled").on('click', function () {
                var a = $("#ButtonSet_Radio").buttonset("option", 
                                                 "disabled");
                $("#log").html(a);
            });
        });
    </script>
</body>
</html>

輸出:

jQuery UI Buttonset disabled Option

參考:https://api.jqueryui.com/buttonset/#option-disabled


相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 jQuery UI Buttonset disabled Option。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。