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

  • Home
  • SEARCH
  • 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 3954152
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:03:43+00:00 2026-05-20T02:03:43+00:00

I have a simple HTML table of options here: <table> <tr> <td>blue</td> <td>green</td> </tr>

  • 0

I have a simple HTML table of options here:

<table>
  <tr>
    <td>blue</td>
    <td>green</td>
  </tr>
  <tr>
    <td>red</td>
    <td>cream</td>
  </tr>
</table>

The CSS with the relevant styles:

td { background-color: #FFF; border: 1px solid #3F3F3F; cursor: pointer; }
td.selected { color: #D93A2C; border: 1px solid #D93A2C; }

Looks like this:

HTML Table

When I click on one of the table cells, I want the border and text to be red. So I use jQuery to toggle the ‘.selected’ class using the following code.

$('td').each(function(){
    $(this).click(function(){
        $(this).toggleClass('selected');
    });
});

However the result is this:
HTML Table Cells Selected

The first table cell (blue) is the only one that looks as I want when selected. I need all the borders of the selected cell to be highlighted.

Any ideas on how to achieve this? I’m not opposed to ditching tables if someone can suggest a better way.

  • 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-20T02:03:43+00:00Added an answer on May 20, 2026 at 2:03 am

    This works nicely for me:

    <style type="text/css">
        table { border: 1px solid #000; border-collapse: collapse; }
        td { border-top: 1px solid #000; border-left: 1px solid #000; }
        td.selected { border: 1px solid #F00; }
    </style>
    
    <table>
        <tr>
            <td>blue</td>
            <td>green</td>
        </tr>
        <tr>
            <td>red</td>
            <td class="selected">yellow</td>
        </tr>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple html table element. <table border=2 cellpadding=5 cellspacing=0 width=40%> <tr><td> aaa
I have a simple HTML Table (10 columns x 500 rows). When the page
I have a simple HTML table which is bound using knockoutJS. However, I've added
I'm trying to have a simple html table, that highlights a row as a
I have a simple table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
I have the following task: there are a simple table from mysql database: <html>
I have a very simple HTML table with 4 columns: Facility Name, Phone #,
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple HTML page with svg like this: <div id=plan> <svg xmlns=http://www.w3.org/2000/svg version=1.1>
I have a simple html form. This form has a specific width and margin

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.