How to hide a table row if date in td is older than today's date?

前端 未结 2 616
情话喂你
情话喂你 2021-01-27 19:56

As a Dr. Frankenstein of coding, I have managed to cobble together a table as exampled [here][1], utilising datatables and UK Date Sorting. The final piece of this puzzle is to

2条回答
  •  孤街浪徒
    2021-01-27 20:23

    Give that particular td some class say "clsdate".Then point the class and find the html and convert that to date. Find the difference and do the necessary

    $('table').find(".clsdate").each(function(index,element){
      var tdDate=new Date($(element).html());
      var currDate=getDate();
      var diff=currDate-tdDate;
       if(diff<0)
       {
         $(element).parent('tr').css('display','none');
       }
    });
    

提交回复
热议问题