Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!