第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過單擊復選框停用日期選擇器上的周末

通過單擊復選框停用日期選擇器上的周末

尚方寶劍之說 2022-12-29 13:59:56
我嘗試編寫一些 JavaScript 代碼列表,但現(xiàn)在陷入了日期選擇器的問題。目標是:選中“僅在工作日”復選框時,必須停用日期選擇器上的周末日期(周六和周日)。我試過了,但到目前為止還沒有用。這是我的 HTML 和 JavaScript 代碼。誰能幫我這個?謝謝!$(function() {      $( "#weekday" ).click(function() {        if ($(this).is('checked')) {          $("#startdate").datepicker({            beforeShowDay: $.datepicker.noWeekends,            dateFormat: "dd'.'mm'.'yy",            firstDay: 1,            showOtherMonths: true,            selectOtherMonths: true          })          $("#enddate").datepicker({            beforeShowDay: $.datepicker.noWeekends,            dateFormat: "dd'.'mm'.'yy",            firstDay: 1,            showOtherMonths: true,            selectOtherMonths: true          })        } else {          $("#startdate").datepicker({            dateFormat: "dd'.'mm'.'yy",            firstDay: 1,            showOtherMonths: true,            selectOtherMonths: true          })          $("#enddate").datepicker({            dateFormat: "dd'.'mm'.'yy",            firstDay: 1,            showOtherMonths: true,            selectOtherMonths: true          })        }      })    })<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">  <link rel="stylesheet" href="/resources/demos/style.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><body>  <input type="checkbox" id="weekday" name="weekday" value="weekday">  <label for="weekday">Only during working days</label><br>  <p>Start Date: <br><input type="text" id="startdate" name="startdate"></p>  <p>End Date: <br><input type ="text" id="enddate" name="enddate"></p>  <p>Quantity: <br><input type="text" id="quantity" name="quantity"><br></p>  <br>  <input type="submit" value="Calculate"></body>
查看完整描述

1 回答

?
慕蓋茨4494581

TA貢獻1850條經(jīng)驗 獲得超11個贊

  • 不要click在復選框上使用事件,使用change

  • if ($(this).is('checked')) {- 它的is(':checked')

  • 不要在復選框處理程序中初始化日期選擇器,單獨初始化它們

  • 不要重新初始化它們,option而是使用更改特定設置的方法

$(function() {


  $("#startdate").datepicker({

    dateFormat: "dd'.'mm'.'yy",

    firstDay: 1,

    showOtherMonths: true,

    selectOtherMonths: true

  })


  $("#enddate").datepicker({

    dateFormat: "dd'.'mm'.'yy",

    firstDay: 1,

    showOtherMonths: true,

    selectOtherMonths: true

  })


  $("#weekday").change(function() {

      if ($(this).is(':checked')) {

        $("#startdate, #enddate").datepicker('option', 'beforeShowDay', $.datepicker.noWeekends)

      } else {

        $("#startdate, #enddate").datepicker('option', 'beforeShowDay', null)

      }

    })

})

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<link rel="stylesheet" href="/resources/demos/style.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>



<body>

  <input type="checkbox" id="weekday" name="weekday" value="weekday">

  <label for="weekday">Only during working days</label><br>

  <p>Start Date: <br><input type="text" id="startdate" name="startdate"></p>

  <p>End Date: <br><input type="text" id="enddate" name="enddate"></p>

  <p>Quantity: <br><input type="text" id="quantity" name="quantity"><br></p>

  <br>

  <input type="submit" value="Calculate">

</body>


查看完整回答
反對 回復 2022-12-29
  • 1 回答
  • 0 關注
  • 98 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號