如何在jQuery UI中禁用一个日期选择器
为了禁用jQuery UI中的日期选择器,我们将使用disable()方法,下面将讨论这个方法。
jQuery UI disable()方法是用来禁用日期选择器的。
语法:
$( ".selector" ).datepicker( "disable" )
参数:该方法不接受任何参数。
返回值:该方法返回一个对象值
方法:首先,添加你的项目所需的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>
示例:
<!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("disable");
});
</script>
</head>
<body>
<p>Enter Date: <input type="text" id="gfg" /></p>
</body>
</html>
输出: