Am trying to delete/remove/disable the options of a select on click of a span. I am trying to remove only those options whose values are lower than the current time (values are total minutes, I find current time and convert to total minutes, before comparing.)
HTML:
<span class="flatpickr-day today">22</span>
<div class="mvvwb_sel_wrap">
<select name="mvvwb_timeStart">
<option value="540">09:00</option>
<option value="600">10:00</option>
<option value="660">11:00</option>
<option value="720">12:00</option>
<option value="780">13:00</option>
<option value="840">14:00</option>
<option value="900">15:00</option>
<option value="960">16:00</option>
<option value="1020">17:00</option>
<option value="1080">18:00</option>
<option value="1140">19:00</option>
</select>
</div>
JS:
$('.flatpickr-day.today').click(function () {
var time = new Date();
var currentTime = time.toLocaleString('en-US', { hour: 'numeric', hour12: false });
var currentTimeMinutes = currentTime*60;
$(".mvvwb_sel_wrap select > option").each(function() {
var optionTime = parseInt(this.value);
if(optionTime < currentTimeMinutes) {
this.remove();
}
});
});
The 3 other ways that I tried that flat out didn't work:
this.prop('disabled',true);
this.attr('disabled','disabled');
this.css('display','none');