Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:11:36+00:00 2026-05-26T22:11:36+00:00

I am encountering a problem assigning classes and hidding and showing td ‘s. Here

  • 0

I am encountering a problem assigning classes and hidding and showing td‘s.
Here is my HTML:

<table id="fundTable">
    <tr> 
         <td class="rentability"> <span class="someClass"> 0.12 </span> </td>
         <td class="absoluteResult">0.66</td>
    </tr>
    <tr> 
         <td class="rentability"> <span class="someClass"> -0.24  </span> </td>
         <td class="absoluteResult">-.45</td>
    </tr>
</table>

Here is my Javascript (onchange):

$('#fundTable tr').each(function() {
    formatedAbsoluteResult = 'SOME NUMBER'
    $(this).find('td[class=absoluteResult]').fadeOut(100).html(formatedAbsoluteResult).fadeIn(100)
    if (formatedAbsoluteResult < 0)
        $(this).find('td[class=absoluteResult]').removeClass('green').addClass('red')
    else 
        $(this).find('td[class=absoluteResult]').removeClass('red').addClass('green')
}

The idea is to display the number in green if it is positive, by assigning the appropriate class. In red otherwise. This code works perfectly when I run it once on page load. Then, the td‘s that have an assigned class (either red or green) are not updated anymore (onchange), whereas the others are on:

$(this).find('td[class=absoluteResult]').fadeOut(100).html(formatedAbsoluteResult).fadeIn(100)

I do not understand this behaviour. Any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:11:36+00:00Added an answer on May 26, 2026 at 10:11 pm

    I think a slight adjustment of your overall design of this block will help.

    This seems to do what you are trying to accomplish (live demo at jsFiddle). Don’t forget to change the parts where I improvised:

        $("#testing").keyup(function() {
        $("#fundTable tr").each(function() {
           formattedAbsoluteResult = 
            $(this).find("td.absoluteResult").fadeOut(100, function () {
                if (formattedAbsoluteResult < 0)
                {
                    $("#fundTable tr").find("td.absoluteResult").removeClass("green").addClass("red");
                }
                else
                {
                    $("#fundTable tr").find("td.absoluteResult").removeClass("red").addClass("green");
                }
            }).html(formattedAbsoluteResult).fadeIn(100);
        });
    });
    

    Notice the callback function used, also “keyup” instead of “onchange”, but you can use whatever you need. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am encountering a problem using CFGRID with JQuery. Here are the sample codes
I am encountering a problem loading an HTML file in an editor pane and
I am encountering a problem with string formatting while trying to get only the
I recently installed Ubuntu Jaunty and I'm encountering a problem when I try to
The problem I am encountering is that for my login form I have to
I´m encountering this problem trying to mock some objects that receive complex lambda expressions
I suddenly started encountering this problem out of nowhere. My 'Manage Categories' page is
I am encountering a problem when using LINQ in C#, I am constantly getting
I am encountering a problem which is how do I convert input strings like
Hello, it's really the first time for me to post. I'am encountering a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.