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

前端 未结 2 643
情话喂你
情话喂你 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:36

    $(document).ready(function() {
    
        $("#table_id").dataTable({"aoColumnDefs" : [
          {"aTargets" : [2] , "sType" : "uk_date"}]});
    
      $('TD.date').each(function( index ) {  
        var q = new Date();
        var m = q.getMonth();
        var d = q.getDay();
        var y = q.getYear();
    
        var date = new Date(y,m,d);
        if(new Date($(this).text()) < date)    {
    
            $(this).parent().attr("style", "display: none")
        }
          });
    
    });
    

    and add a date class to the column that contains the date.

提交回复
热议问题