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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:18:17+00:00 2026-05-11T15:18:17+00:00

I am using a tutorial from Imar Spaanjaars’ web site to make an entire

  • 0

I am using a tutorial from Imar Spaanjaars’ web site to make an entire table row clickable and have a hover effect on it also. Once the user hovers over the table row it removes the pre defined background color for that row. I want to make it so that way it does not overwrite this style. How might I do that?

    <script type='text/javascript'>     function ChangeColor(tableRow, highLight)     {     if (highLight)     {       tableRow.style.backgroundColor = '#dcfac9';     }     else     {       tableRow.style.backgroundColor = 'white';     }   }    function DoNav(theUrl)   {   document.location.href = theUrl;   }   </script> 

If you have any better suggestions to accomplish this task I would love to hear them!

My tr tag has a bgcolor tag in it that is set by my php if that specific piece of mail has been read or not.

  • 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. 2026-05-11T15:18:18+00:00Added an answer on May 11, 2026 at 3:18 pm

    If the original background color is specified via a stylesheet or (as in your case) a legacy bgcolor attribute, then you can just clear out the style on the element when you’re done, and it’ll revert:

    function ChangeColor(tableRow, highLight) {   if (highLight)   {     tableRow.style.backgroundColor = '#dcfac9';   }   else   {     tableRow.style.backgroundColor = '';   } } 

    That said, you’d probably be better off using a CSS class and associated rules to represent the highlighted state of the row and add/remove that as you like:

    tr { backgroundColor: <whatever> } tr.highlighted { backgroundColor: #dcfac9 } 

    Then your Javascript becomes

    function ChangeColor(tableRow, highLight) {     if(highLight)      {         tableRow.className = 'highlighted';     }      else      {         tableRow.className = '';     } } 

    In addition to keeping specific styles out of your script and markup (where they become difficult to maintain over time), this lets you add or change hover styles (say, bold text, or a border) without adding complexity to the code.

    If you have access to a Javascript library such as Prototype, Ext.js or Dojo, then you can use their class manipulation functions instead, which will handle the case where you want to preserve an existing className, or are using multiple classes for on a single element.

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

Sidebar

Related Questions

Does anyone have a good articles or tutorial on correctly using dispose and IDisposable.
I am using following a tutorial from here: http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/ This is the script I
I am using tutorial (now inaccessible) UITableView - Searching table view. but I really
I have a tutorial from a website Net Tuts which is used to upload
I am trying to parse JSON in an Adobe Flex app, using http://www.mikechambers.com/blog/2006/03/28/tutorial-using-json-with-flex-2-and-actionscript-3/'>This Tutorial
Does anyone know any good tutorial about using NAnt for native code build process
Is there a good tutorial on using regular expressions, especially with grep ? I
Does anybody know of an up to date tutorial on using Ajax with ASP.net
What references offer a good summary/tutorial for using RDF/OWL? There seem to be enough
I am following a VB tutorial to do some HTML manipulation using LINQ It

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.