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

171
Visualizações
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 à 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