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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:16:19+00:00 2026-05-31T08:16:19+00:00

I have some table rows with checkboxes. <table cellpadding=0 class=action_table> <tbody class=action_table_body> <tr class=action_table_row>

  • 0

I have some table rows with checkboxes.

<table cellpadding="0" class="action_table">
    <tbody class="action_table_body">
        <tr class="action_table_row">
            <td class="action_table_checkbox"><input type="checkbox" id="chkbx_1"></td>
            <td class="action_table_checkbox"><input type="checkbox" id="chkbx_2"></td>
        </tr>
    </tbody>
</table>

I’m toggling the color of the rows on mouseover events.

$(".action_table_row").mouseenter(function() {
    $(this).css({background:'#FCF6CF'});
}).mouseleave(function() {
    $(this).css({background:'#F3F3F3'});
});

I also want to highlight rows that are checked:

$('input:checkbox').click(function() {
    if ($(this).attr('checked')) {
        $(this).parent().parent().css({background:'#ff0000'});
    } else {
        $(this).parent().parent().css({background:'#F3F3F3'});
    });
});

The problem is when these two interact. I want to maintain the highlighting if a row is checked, thus overriding the mouseenter/mouseleave.

I tried this, but it seems to operate across all rows/checkboxes instead of the specific row with the checked checkbox.

$(".action_table_row").mouseenter(function() {
    if ($(this + ':checkbox').attr('checked') == false) {
        $(this).css({background:'#FCF6CF'});
    }
}).mouseleave(function() {
    if ($(this + ':checkbox').attr('checked') == false) {
        $(this).css({background:'#F3F3F3'});
    }
});

How do I keep the css from changing if a row’s checkbox is clicked?

  • 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-31T08:16:20+00:00Added an answer on May 31, 2026 at 8:16 am

    Use CSS classes and the not selector. Also note that I replace parent with closest('tr').

    Not changing checked rows:

    $(".action_table_row:not(.checked)").mouseenter(function() {
        $(this).css({background:'#FCF6CF'});
    }).mouseleave(function() {
        $(this).css({background:'#F3F3F3'});
    });
    

    Setting the checked class instead:

    $('input:checkbox').click(function() {
        if ($(this).attr('checked')) {
            $(this).closest('tr').addClass('checked');
        } else {
            $(this).closest('tr').removeClass('checked');
        });
    });
    

    Try to avoid using inline styling as much as you can. It’s a lot easier to handle all styling in the stylesheet instead of in several places.

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

Sidebar

Related Questions

I have something like this: <table> <tr><td><input type=checkbox id=checkbox1></input></td><td><input type=text disabled=disabled id=textInput1></input></td></tr> <tr><td><input type=checkbox
I have some table rows <tr class=b_row> <td> <div class=cpt> <h2> <a href=/ref/ref/1.html>example</a> </h2>
i have some rows of data displayed in a table and on mouse over
I have a table with a column 'A'. Some rows have 14 digits for
I have a table and I am hiding some rows. I want to get
I have a table. Some rows are dynamically added by jquery. The first <td>
I have a table, containing rows, contaning cells - and some of them contain
Ok, I have a table which contains multiple rows. Each row contains some data
I have some table structure: <tr class=row-2><tr> <tr class=row-3>..<tr> <tr class=row-4>..<tr> <tr class=row-5>..<tr> <tr
I have a Jquery Mobile site with a table. Table rows include checkboxes in

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.