jQuery UI 由 GUI 小部件、視覺效果和使用 HTML、CSS 和 jQuery 實現的主題組成。 jQuery UI 非常適合為網頁構建 UI 接口。 jQuery UI Buttonset 小部件用於為一組相關按鈕提供視覺分組。
jQuery UI 按鈕集 option() 方法用於返回代表當前按鈕集選項的鍵值對對象。
用法:
$( ".selector" ).buttonset( "option", optionName, value );
參數:此方法接受兩個參數,如下所示:
- optionName:這是用戶要設置的選項的名稱。
- value:這是為指定選項設置的值。
返回值:此方法返回表示當前按鈕設置選項的鍵值對對象。
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 按鈕集 option() 方法。
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 option() Method</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_option"
style="padding:5px 15px; margin-top:40px;"
value="Get the option value">
<div id="log"></div>
</center>
<script>
$(document).ready(function () {
$("#ButtonSet_Radio").buttonset();
$("#Button_for_option").on('click', function () {
var a = $("#ButtonSet_Radio")
.buttonset("option","disabled", true);
$("#log").html(a);
});
});
</script>
</body>
</html>
輸出:
參考: https://api.jqueryui.com/buttonset/#method-option
相關用法
- jQuery UI Buttonset items用法及代碼示例
- jQuery UI Buttonset disabled用法及代碼示例
- jQuery UI Buttonset destroy()用法及代碼示例
- jQuery UI Buttonset disable()用法及代碼示例
- jQuery UI Buttonset enable()用法及代碼示例
- jQuery UI Buttonset widget()用法及代碼示例
- jQuery UI Buttonset refresh()用法及代碼示例
- jQuery UI Buttonset create用法及代碼示例
- jQuery UI Spinner option()用法及代碼示例
- jQuery UI Accordion option()用法及代碼示例
- jQuery UI dialog option()用法及代碼示例
- jQuery UI Tabs option()用法及代碼示例
- jQuery UI Tooltips option()用法及代碼示例
- jQuery UI datepicker option()用法及代碼示例
- jQuery UI Slider option()用法及代碼示例
- jQuery UI Progressbar option()用法及代碼示例
- jQuery UI Controlgroup option()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 jQuery UI Buttonset option() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。