jQuery UI 由 GUI 小部件、視覺效果和使用 HTML、CSS 和 jQuery 實現的主題組成。 jQuery UI 非常適合為網頁構建 UI 接口。 jQuery UI 按鈕集小部件用於為一組相關按鈕提供視覺分組。
jQuery UI 按鈕集項目選項用於設置或獲取指定按鈕集小部件的項目。
用法:用於使用 items 選項初始化按鈕集。
$( ".selector" ).buttonset({ items:"GFG" });
設置項目選項。
$( ".selector" ).buttonset( "option", "items", "GFG" );
獲取項目選項的價值。
var items = $( ".selector" ).buttonset( "option", "items" );
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 items 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_items"
style="padding:5px 15px; margin-top:40px;"
value="Value of the items option">
<div id="log"></div>
</center>
<script>
$(document).ready(function () {
$("#ButtonSet_Radio").buttonset({
items:"GFG"
});
$("#ButtonSet_Radio").buttonset("option", "items", "GFG");
$("#Button_for_items").on('click', function () {
var a = $("#ButtonSet_Radio")
.buttonset("option", "items");
$("#log").html(a);
});
});
</script>
</body>
</html>
輸出:
參考: https://api.jqueryui.com/buttonset/#option-items
相關用法
- jQuery UI Buttonset option()用法及代碼示例
- 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 Mobile Button corners用法及代碼示例
- jQuery UI Tooltips hide用法及代碼示例
- jQuery Mobile Rangeslider disabled用法及代碼示例
- jQuery UI Datepicker dayNamesShort用法及代碼示例
- jQuery UI Tooltips content用法及代碼示例
- jQuery UI Selectmenu position用法及代碼示例
- jQuery UI Selectmenu width用法及代碼示例
- jQuery Mobile Popup transition用法及代碼示例
- jQuery UI Spinner option()用法及代碼示例
- jQuery UI Tooltips track用法及代碼示例
- jQuery UI Button icon用法及代碼示例
- jQuery UI Button disabled用法及代碼示例
- jQuery Mobile Selectmenu closeText用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 jQuery UI Buttonset items Option。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。