how to restrict future month using javascript

前端 未结 2 570
北恋
北恋 2021-01-28 12:14

I\'m using two dropdown(month, year). I\'ve to restrict future month based on year. suppose if I choose \'2014\', it should show the months till January.I don\'t have any clue h

2条回答
  •  孤城傲影
    2021-01-28 13:08

    $('#year').on('change',function() {

    var option=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov","Dec"];

    var currMon= (new Date).getMonth();

    var currYear = (new Date).getFullYear();

    $('#month').html('');

    if(currYear == $('#year :selected').text()&& currMon==0){

        for(i=0; i<=currMon; i++)
          {
            $('#month').append($("

    });

提交回复
热议问题