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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:26:03+00:00 2026-06-12T01:26:03+00:00

In reference to my earlier post : My HTML <table class=table table-bordered table-condensed table-striped>

  • 0

In reference to my earlier post:

My HTML

<table class="table table-bordered table-condensed table-striped">
    <thead>
        <tr>
            <th>Col 1</th>
            <th>Col 2</th>
            <th>Col 3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><strong>Data 1</strong></td>
            <td>Data 2</td>
            <td>Data 3</td>
        </tr>
        <tr>
            <td><strong>Data 1</strong></td>
            <td>Data 2</td>
            <td>Data 3</td>
        </tr>
        <tr>
            <td><strong>Data 1</strong></td>
            <td>Data 2</td>
            <td>Data 3</td>
        </tr>
    </tbody>
</table>

jQuery

$(document).ready(function(){
    $('table.table-striped tr').on('click', function () {
        $(this).find('td').css('background-color', '#ff0000');

         // toggleClass doesn't seem to work

     });
 });

I’m trying to toggle the row color off an on via my click event. Any idea if this is possible using a user defined css selector?

  • 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-06-12T01:26:05+00:00Added an answer on June 12, 2026 at 1:26 am

    You may try this

    CSS

    .bg{background-color:#ff0000 !important;}​
    

    JS

    $(document).ready(function(){
        $('table.table-striped tbody tr').on('click', function () {
            $(this).closest('table').find('td').removeClass('bg');
            $(this).find('td').addClass('bg');
        });
    });​
    

    DEMO.

    Update: For toggling

    $(document).ready(function(){
        $('table.table-striped tbody tr').on('click', function () {
            $(this).find('td').toggleClass('bg');
        });
    });​
    

    DEMO.

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

Sidebar

Related Questions

Problem with Maven Dependency. Hello All, This is in reference to my earlier post
In reference to an earlier post ( PDF Report generation ) I have decided
I am attempting to assign a column by reference after I subsetted a data.table
I reference the current page in a class with Page page = HttpContext.Current.CurrentHandler as
I had some good insight to an earlier post regarding this, but I have
This appears similar to an earlier post: ld cannot find an existing library But
Sometime earlier this week i saw a reference to a commercial library (think was
I have a $database object that I need to reference inside another class. Would
I am using a listbox in a data template - and from an earlier
Earlier today I was working on my homework for my C# class LINK TO

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.