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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:41:58+00:00 2026-05-25T21:41:58+00:00

I have have a table with the class pretty. Each row has a checkbox

  • 0

I have have a table with the class “pretty”.

Each row has a checkbox next to it that selects the data using a form.

I want to be able to click the cell and have the checkbox ticked/unticked.

I have this working using

$(document).ready(function () {
  $('.pretty tr').toggle(function() {
      $(this).find(':checkbox').attr('checked', true);  
  }, function() {
      $(this).find(':checkbox').attr('checked', false);
});

});

In addition to this I want the cells background colour to change when the checkbox has been selected and unchange if its deselected.

I have not had any luck doing this, any idea’s?

I have tried adding

$(this).addClass('cssclassname');

To the above with no luck 🙁

Edit just an update the class “pretty” already has the following css which makes the data in the table differ in colour for each row.

It seems when I try the jquery toggleClass function it doesn’t apply it over the already existing CSS?

    table.pretty {
  background: whitesmoke;
  border-collapse: collapse;
}
table.pretty th, table.pretty td {
  border: 1px silver solid;
  padding: 0.2em;
}
table.pretty th {
  background: gainsboro;
  text-align: left;
}
table.pretty caption {
  margin-left: inherit;
  margin-right: inherit;
}
table.pretty tr:nth-child(odd)    { background-color:#eee; }
table.pretty tr:nth-child(even)    { background-color:#fff; }
  • 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-25T21:41:59+00:00Added an answer on May 25, 2026 at 9:41 pm

    See this DEMO

    An alternative to your Jquery is HERE

    Lets check the demo HERE . I am not sure it is the best way to do it

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

Sidebar

Related Questions

I have a table of data that I want to grab text from, stick
I have a class hierarchy that I want to map across several tables using
Let's say I have a table that represents a super class, students . And
I have a class A that inherits UITableViewCell (to customize a table cell). It
I have a HTML table that displays rows of records and has a column
I have a pretty big web application that I created last year using ASP.NET
I have a pretty basic form that shows quiz questions along with choices: <%=
I have a HTML page with about 50 tables on it. Each table has
I have this class called Table: class Table { public string Name { get
I have a table called Users ( class User < ActiveRecord::Base ) and a

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.