Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
Jquery remove() only skips select options, rather than deleting them

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');
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda