Make item disappear according to system date

0

I have several 'boxes' with dates in html, example:

<div id="agenda">
  <a href="javascript:void" class="web-thumb">
     <span class="data">13 set</span>
     <span class="hora">10h30</span>
     <p class="tema green-sage">eSocial</p>
  </a>
  <a href="javascript:void" class="web-thumb">
     <span class="data">13 set</span>
     <span class="hora">14h</span>
     <p class="tema green-sage">eSocial</p>
  </a>
  <a href="javascript:void" class="web-thumb">
    <span class="data">14 set</span>
    <span class="hora">10h30</span>
    <p class="tema green-sage">eSocial</p>
  </a>            
</div>

I need to see jQuery the date boxes below the system disappear.

    
asked by anonymous 22.09.2016 / 22:29

1 answer

1

Using Moment.js , and jQuery, this is quite simple.

$("a.web-thumb").each(function() {
    var data_atual = moment();
    var data_teste = moment("13/09/2016", "dd/MM/yyyy"); // Aqui eu coloquei fixo, mas você 
                                                         // pode usar, por exemplo, 
                                                         // $(this).find("span.data").text(), 
                                                         // mas no formato "13/09/2016", e não 
                                                         // "13 set", como na pergunta.
    if (data_teste.diff(data_atual) < 0) 
    {
        $(this).hide();
    }
});

Place this event in $(document).ready(function() { ... }) .

    
26.09.2016 / 16:18