日期对象 tab切换前一天 前一周 前30天值

  • 今天项目有需求 有三个div按钮 点击 前面的input内容要跟着改变 | 昨天 | 前7天 | 前30天

      $('body').on('click', '.btn_time div', function () {
          if ($(this).attr('data-num') == 0)
              $('.creattime').val(new Date(new Date().getTime() - 24 * 60 * 60 * 1000 ).Format('yyyy-MM-dd hh:mm'));
          if ($(this).attr('data-num') == 1)
              $('.creattime').val(new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 7).Format('yyyy-MM-dd hh:mm'));
          if ($(this).attr('data-num') == 2)
              $('.creattime').val(new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 30).Format('yyyy-MM-dd hh:mm'));
          $(this).siblings().removeClass('btn_active');
          $(this).addClass('btn_active');
      })
    
  • HTML

      
  • 昨天
    近7天
    近30天

洱月

你可能感兴趣的:(日期对象 tab切换前一天 前一周 前30天值)