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

165
Vistas
Jquery if/else remove class on dynamic data

Hello im trying to append and remove a css class depending on what value is in the div

if the value is equal to custom now i add a class that removes the :after appended to my text.

I want to reapply the class if it otherwise.

setInterval(function() {
  $('.monthappend').each(function() {
    var text = $(this).text();
    $(this).text(text.replace('$0', 'CUSTOM'));

    if ($(this).text() == 'CUSTOM') {
      $('.monthappend').addClass('without-after-element');
    } else {
      $('.monthappend').removeClass('without-after-element');
    }
  });
}, 1000);

this else statement didnt work... i tried adding another interval check after this one

<script>
setInterval(function() {
  $('.monthappend').each(function() {
    if ($(this).text() != 'CUSTOM') {
      $('.monthappend').removeClass('without-after-element');
    }
  });
}, 2000);
</script>

but this just caused the appended text to appear and reappear in a loop.

Please help!

site im working this code on https://staging-homecarepulse.kinsta.cloud/pricing-calc-2/

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