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

252
Visualizações
Move Div to Another Div if the date is old

I have a webpage for all events, there is two section upcoming events and past events, both section has multiple divs, if the date of the div in upcoming event is older than today, it should automatically move to past events, and should be deleted from upcoming events.

I already have a function to sort the divs in date wise

The Below snippet is one of my divs and fuction to sort.

// Function to sort the events by date.

function ddmmyyyy(s) {
  var part = s.split(/\//),
    date = new Date();
  date.setYear(part[2]);
  date.setMonth(part[1] - 1);
  date.setDate(part[0]);
  return date;
}

// In Descending Order
function ddmmyyyClassSortDescending(a, b) {
  var A = ddmmyyyy(a.getAttribute("data-event-date")),
    B = ddmmyyyy(b.getAttribute("data-event-date"));
  return A < B ? 1 : -1;
}

// In Ascending Order
function ddmmyyyClassSortAscending(a, b) {
  var A = ddmmyyyy(a.getAttribute("data-event-date")),
    B = ddmmyyyy(b.getAttribute("data-event-date"));
  return A > B ? 1 : -1;
}

$.fn.sortChildren = function(cmp) {
  var self = this,
    children = $.makeArray(this.children()).sort(cmp);
  $.each(children, function(i, child) {
    self.append(child);
  });
  return self;
};

$(function() {
  $(".past-Events").sortChildren(ddmmyyyClassSortDescending);
});
<div id="past-Events">Past Event
  <div class="shadow p-3 mb-5 bg-white rounded" id="distinguished-Lectures" data-event-date="15/12/2021">
    <center>
      <b>
         <h5>
             <font color="#183a1d">IMSc Distinguished Lecture</font>
         </h5>
      </b>
    </center>
  </div>
</div>

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