Jquery datepicker在月份更改时未安装第二次

时间:2017-10-03 07:52:22

标签: jquery

$(document).on('change','select#month',function(e)
{
    e.preventDefault();
    var month = $(this).val(); 
    if(month == "01" || month == "03" || month == "05" || month == "07"  || month == "08"  || month == "10" || month == "12"  ) { var eday = 31; }
    if(month == "04" || month == "06" || month == "09" || month == "11") { var eday = 30; }
    if(month == "02") { var eday = 28; }


    var today = new Date();
    var startDate = new Date(today.getFullYear(), month-1, 1);
    var endDate = new Date(today.getFullYear(), month-1, eday);

    $('#date-picker').datepicker(
        {
            autoclose: true,
            startDate: startDate,
            endDate: endDate

        });
});

第一次使用其工作文件,但是当我第二次更换月份时,它无法正常工作。第二次显示我选择的上个月细节。

1 个答案:

答案 0 :(得分:0)

TextView