jQuery-UI datepicker default date

后端 未结 7 1395
盖世英雄少女心
盖世英雄少女心 2020-11-29 03:34

I have a problem with the jQuery-UI datepicker, I have searched and searched but I didn\'t find the answer. I have the following code:



        
7条回答
  •  粉色の甜心
    2020-11-29 04:30

    Jquery Datepicker defaultDate ONLY set the default date that you chose on the calendar that pops up when you click on your field. If you want the default date to APPEAR on your input before the user clicks on the field you should give a val() to your field. Something like this:

    $("#searchDateFrom").datepicker({ defaultDate: "-1y -1m -6d" });
    $("#searchDateFrom").val((date.getMonth()) + '/' + (date.getDate() - 6) + '/' + (date.getFullYear() - 1));
    

提交回复
热议问题