jQuery中的搜索日期

时间:2019-07-18 08:05:56

标签: jquery

我有两个表格,表格1包含年份和月份字段以及一个搜索按钮,我想根据员工的年份和月份进行搜索。

$(document).ready(function() {
  $("#form2").hide();
  var now = new Date();
  var day = ("0" + now.getDate()).slice(-2);
  var month = ("0" + (now.getMonth() + 1)).slice(-2);
  var year = now.getFullYear();

  $('#year').val(year);
  $('#month').val(month);
  $("#hide").click(function() {
    $("#form1").hide();
    $("#form2").show();
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id='form1'>
  <div class="form-group">
    <label>year:</label>
    <input type="text" id="year" name="date" class="form-control">
  </div>
  <div class="form-group">
    <label>month:</label>
    <input type="text" id="month" name="date" class="form-control">
  </div>
  <div class="form-group col-md-offset-5 ">
    <button class="btn btn-success " id="hide">Rechercher</button>
  </div>
</div>
<div id='form2'>
  <table class="table table-bordered" id="mytable">
    <tr>
      <th>date</th>
      <th>name</th>
    </tr>
    <tr>
      <td>22/01/2019</td>
      <td>salary1</td>
    </tr>
    <tr>
      <td>22/03/2018</td>
      <td>salary2</td>
    </tr>
  </table>
</div>

0 个答案:

没有答案