jQuery UI Controlgroup option(optionName)方法
jQuery UI由GUI小部件、视觉效果和使用jQuery、CSS和HTML实现的主题组成。 jQuery UI非常适合为网页建立UI界面。一个控制组被用来分组各种输入部件,如复选框,按钮等。控制组有助于对一个表单的所有元素应用共同的属性。
jQuery UI Controlgroup option(optionName)方法返回当前与指定optionName相关的值。
语法:
var isDisabled = $( ".selector" )
.controlgroup( "option", "disabled" );
参数:它接受一个单一的参数optionName,用来存放选项的名称。
返回值:它返回当前与指定的optionName相关的选项。
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(optionName)方法。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src=
"https://code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"https://code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<script>
(document).ready(function () {
("#divID").controlgroup();
("#divID").controlgroup("disable");
("#btn").on('click', function () {
var isDisable = $("#divID")
.controlgroup( "option", "disabled" );
console.log(isDisable);
});
});
</script>
</head>
<body>
<center>
<h1 style="color:green">
GeeksforGeeks
</h1>
<h3>jQuery UI Controlgroup option(optionName) Method</h3>
<div id="divID">
<label for="radio_1">Men</label>
<input type="radio" name="type" id="radio_1">
<label for="radio_2">Women</label>
<input type="radio" name="type" id="radio_2">
<select>
<option>Cricket</option>
<option>Hockey</option>
<option>Tennis</option>
<option>Football</option>
</select>
<label for="official">Official</label>
<input type="checkbox" name="official" id="official">
</div>
<br>
<input type="button" id="btn"
style="padding:5px 15px; margin-top:50px;"
value="option() Method">
</center>
</body>
</html>
输出: