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 630221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:49:55+00:00 2026-05-13T19:49:55+00:00

I have a page I created with jQuery, and in this page is a

  • 0

I have a page I created with jQuery, and in this page is a table where the table rows have classnames that identify them as a certain color (i.e. tr class=”yellowclass”).

The user is able to filter rows by clicking a checkbox that will show/hide tables of a certain color.

My problem is that the table is generated on the fly via getJSON requests. to add the new content to the table, I first do a children().remove() on the table’s tbody, ($(‘#my_table_tbody’).children().remove()), and then I use appendTo to add the new table information back in.

an example of this function is:

$('#my_table_tbody').children().remove();
$.getJSON("http://my_url.com/my_cgi_bin/my_cgi", {data: mydata}, function(j) {
    var mylength = j.length;
    for (var k = mylength - 1; k >= 0; k--)
        $('<tr class="' + j[k].color + '"><td class="my_first_col_class">' + j[k].data1 + '</td><td class="my_second_col_class">' + j[k].data2 + '</td></tr>').appendTo($('#my_table_tbody'));
});

Now at the end of this function, I am trying to check to see if checkboxes are checked, and if so, to show/hide the new information. For example, to basically call

if (('#my_yellow_color_cb').attr('checked'))
    $('.yellowclass').show();
else
    $('.yellowclass').hide();

The problem is, the page isn’t wanting to “remember” what has been checked. In other words, if the ‘yellowclass’ check box is unchecked, and the page reloads with new table data, the yellowclass class is still showing up, when it really should be hidden.

i suspect this has something to do with the DOM, and creating proper DOM elements that can be shown/hidden. But i don’t know how to do this in my particular situation. I am a systems programmer, and am just doing this to program a tool that would provide our testers with some status info. i am no expert when it comes to JavaScript and have little understanding of the DOM, and can’t seem to figure this one out.

How can I insert into the page so that I can properly show and hide this information?

If I update the page with new table data, and then check and uncheck boxes, then things work fine. But if I load table data, and just check the status of the boxes as they are, it’s not wanting to work. Does jQuery take a little time to get DOM objects created before they can be accessed?

Thanks for any help.

  • 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-13T19:49:55+00:00Added an answer on May 13, 2026 at 7:49 pm

    Perhaps something like this?

    $('#my_table_tbody').children().remove();
    $.getJSON("http://my_url.com/my_cgi_bin/my_cgi", {data: mydata}, function(j) {
        var mylength = j.length;
        for (var k = mylength - 1; k >= 0; k--) {
            var $row = $('<tr class="' + j[k].color + '"><td class="my_first_col_class">' + j[k].data1 + '</td><td class="my_second_col_class">' + j[k].data2 + '</td></tr>');
    
            if ($('#my_yellow_color_cb:checked').length == 0 && $row.is('.yellow'))
                $row.hide();
    
            $row.appendTo('#my_table_tbody');
        }
    });
    

    Basically, each row is created as a DOM fragment and then the conditional is run. If $('#my_yellow_color_cb:checked').length is 0, meaning the yellow color check box is not checked, then .hide() is executed for the row. Then, the row is added to the end of the tbody. You’ll want to extend the if statement with more logic for your other colors.

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

Sidebar

Related Questions

I've created a page that lists information in a table, this information comes from
I have a menu that I've created using jquery that pops-up on certain button
I have a page which contains a jQuery-UI horizontal slider, created using a little
I have created one aspx Page from that i need to access the property
I have created a web page (ASP.NET) that includes a stylesheet to mimic Dynamics
I have a HTML table that displays rows of records and has a column
I have this binding on my page. The page shows a table of items.
I have page that creates a table: http://gupii.co.uk/rap/weekTable.php and I'm using a plugin to
I use jQuery ajax. I have created function: getDatalist() . This function displays a
I have a page that creates a table using backbone.js. each table row is

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.