close

本文說明 datepicker Methods 中的 destroy isDisabled

其銷毀及禁用的方法

一、基本JS/HTML語法

JS:

$("#datepicker").datepicker("destroy");

$("#datepicker").datepicker("isDisabled")

$("#datepicker").datepicker("option", "disabled", true);

二、基本說明

銷毀 datepicker

$("#datepicker").datepicker("destroy");

設定禁用 datepicker

$("#datepicker").datepicker("option", "disabled", true);

是否有禁用 datepicker

$("#datepicker").datepicker("isDisabled")

三、程式內容

<html>
<head>
<title>jquery.datepicker 21</title>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
  $(function() {
    //21-jQuery datepicker Methods destroy isDisabled option
    $("#datepicker").datepicker({
      //設定日期格式
      dateFormat : "yy/mm/dd"//,
    //disabled:true
    });
    $(".destroyDate").bind("click", function() {
      $("#datepicker").datepicker("destroy");
    });
    $(".isDisabledDate").bind(
        "click",
        function() {
          $("#showDateBox").append(
              "是否被停用:" + $("#datepicker").datepicker("isDisabled"));
        });
    $(".setDisabledDate").bind("click", function() {
      $("#datepicker").datepicker("option", "disabled", true);
    });
  });
</script>
</head>
<body>
  <div class="datetest">
    <p class="datag">
      Date: <input type="text" id="datepicker" value="">
    </p>
  </div>
  <div>說明:jQuery datepicker Methods destroy isDisabled option </div>
  <br>
  <div>
    <ul>
      <li><a href="javascript:void(0)" class="destroyDate">設定destroy日期</a></li>
      <li><a href="javascript:void(0)" class="isDisabledDate">isDisabled</a></li>
      <li><a href="javascript:void(0)" class="setDisabledDate">設定Disabled</a></li>
    </ul>
  </div>
  <div id="showDateBox"></div>
</body>
</html>
	

四、執行

圖1

五、測試

Date: 

說明:jQuery datepicker Methods destroy isDisabled option

相關參考:

其它參考:

jQuery教學目錄

其它文章



arrow
arrow

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()