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

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's a much simpler solution: using PlistBuddy, included at /usr/libexec/PlistBuddy… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer The most reliable way would be to actually feature-test it.… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer This is working on Ubuntu 8.04.1 , Python 2.5.2, i… May 12, 2026 at 12:15 am

Related Questions

I am using a tutorial from Imar Spaanjaars' web site to make an entire
I have a tutorial from a website Net Tuts which is used to upload
I don't understand the concept of the fetch function. I am doing a tutorial
I am going to try to build a PHP website using a framework for
I've been a software developer for over twenty years, programming in C, Perl, SQL,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.