jQuery UI datepicker option(optionName, value)方法
jQuery UI datepicker option(optionName, value)方法是用来设置与指定optionName相关的按钮选项的值。
语法:
$( ".selector" ).datepicker( "option", "disabled", true )
参数:
- optionName。要检查的选项。
- value。要检查的值
返回值:该方法返回一个对象值。
方法:首先,添加你的项目所需的jQuery UI脚本。
<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”>
<script src = “https://code.jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
示例 1:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link href=
"https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.10.2.js">
</script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js">
</script>
<script>
(function () {
("#gfg").datepicker();
$("#gfg").datepicker("option", "enable", true);
});
</script>
</head>
<body>
<p>Enter Date: <input type="text" id="gfg" /></p>
</body>
</html>
输出:
示例 2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link href=
"https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.10.2.js">
</script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js">
</script>
<script>
(function () {
("#gfg").datepicker();
$("#gfg").datepicker("option", "disabled", true);
});
</script>
</head>
<body>
<p>Enter Date: <input type="text" id="gfg" /></p>
</body>
</html>
输出: