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:
HTML
<!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:
HTML
<!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>输出:

相关用法
- jQuery UI Datepicker dayNamesShort用法及代码示例
 - jQuery UI Datepicker altFormat用法及代码示例
 - jQuery UI Datepicker altField用法及代码示例
 - jQuery UI Datepicker buttonText用法及代码示例
 - jQuery UI Datepicker appendText用法及代码示例
 - jQuery UI Datepicker autoSize用法及代码示例
 - jQuery UI Datepicker showButtonPanel用法及代码示例
 - jQuery UI Datepicker showOn用法及代码示例
 - jQuery UI Datepicker changeMonth用法及代码示例
 - jQuery UI Datepicker closeText用法及代码示例
 - jQuery UI Datepicker changeYear用法及代码示例
 - jQuery UI Datepicker duration用法及代码示例
 - jQuery UI Datepicker defaultDate用法及代码示例
 - jQuery UI Datepicker dayNamesMin用法及代码示例
 - jQuery UI Datepicker dayNames用法及代码示例
 - jQuery UI Datepicker dateFormat用法及代码示例
 - jQuery UI Datepicker showWeek用法及代码示例
 - jQuery UI Datepicker showOtherMonths用法及代码示例
 - jQuery UI Datepicker showMonthAfterYear用法及代码示例
 - jQuery UI Datepicker showAnim用法及代码示例
 - jQuery UI Datepicker numberOfMonths用法及代码示例
 - jQuery UI Datepicker prevText用法及代码示例
 - jQuery UI Datepicker showCurrentAtPos用法及代码示例
 - jQuery UI Datepicker nextText用法及代码示例
 
注:本文由纯净天空筛选整理自taran910大神的英文原创作品 jQuery UI datepicker option() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
