曜日に基づいてテーブルの行を表示/非表示にしたい。現時点で私が持っているコードを示し/ 24時間の期間ではなく、暦日に基づいて非表示を:)moment.formatの「DDDD」(としてモーメントJSの日付範囲
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" id="button1">Monday</button>
<button type="button" id="button2">Tuesday</button>
<table id="myTable">
<thead>
<tr>
<th>Table</th>
</tr>
</thead>
<tbody>
<tr>
<td class="dates">13/02/2017 12:45 pm</td>
</tr>
<tr>
<td class="dates">14/02/2017 12:45 pm</td>
</tr>
</tbody>
$('#button1').click(function(){
var $dates = $('.dates');
var m = moment().add(1, 'd');
$dates.each(function() {
var date = moment($(this).text(), 'DD/MM/YYYY hh:mm a');
if (date.isBetween(moment(), m)) {
$(this).parent().show();
} else {
$(this).parent().hide();
}
});
});
ありがとうございました。私はこのソリューションについて知りませんでした。 –