美文网首页ant-design
日期对象 tab切换前一天 前一周 前30天值

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

作者: 洱月 | 来源:发表于2017-07-28 09:16 被阅读0次
  • 今天项目有需求 有三个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

      <li class="btn_time">
               <div data-num="0">昨天</div>
               <div data-num="1" class="btn_active">近7天</div>
               <div data-num="2">近30天</div>
       </li>
    

洱月

相关文章

网友评论

    本文标题:日期对象 tab切换前一天 前一周 前30天值

    本文链接:https://www.haomeiwen.com/subject/lvlxlxtx.html