Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda