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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:23:50+00:00 2026-06-18T10:23:50+00:00

A CSS and perhaps Javascript question. I want alternate rows to have different colors,

  • 0

A CSS and perhaps Javascript question. I want alternate rows to have different colors, the default text to be grey in color. However, once an input field has focus I want the new text to be black and then to stay black after the field no longer has focus. Here is what I have done so far:

input {
   font-family:Verdana, Trebuchet MS;
   font-size:11px;
   vertical-align:top;
}

input:focus {
    color: black;
}

input.odd {
   color: #888;
   background:#FFFFB4;
}

input.even {
   color: #888;
   background:#FFD9C8;
}

This code achieves my requirements of alternate rows to have different colors and the default text to be grey in color. However, new text is grey, not black. Then how do I get the new text to stay black.

UPDATED CSS

input {
   font-family:Verdana, Trebuchet MS;
   font-size:11px;
   vertical-align:top;
}

input.odd {
   color: #888;
   background:#FFFFB4;
}

input.even {
   color: #888;
   background:#FFD9C8;
}

input.odd:focus, input.even:focus, input.odd.hasText, input.even.hasText {
    color: black;
}

NEW jQuery CODE

$('input').focus(function() {
   $(this).addClass('hasText');
});
  • 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-18T10:23:51+00:00Added an answer on June 18, 2026 at 10:23 am

    Most likely you want

    input.odd:focus,input.even:focus {
        color: black;
    }
    

    If you mean the text reverts to grey after it loses focus, you will probably need to add a class via javascript once text is entered and have that class match your focus class.

    EDIT

    Something like:

    $('input').focus(function(){
        $(this).addClass('hasText');
    });
    

    Then in your CSS have:

    input.even:focus,input.odd:focus,input.hasText{
        color: black;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found utilities that can compress html, javascript, and css files individually. However,
CSS I have some simple CSS to apply a negative text-indent value on the
Pretty new to jquery/javascript, but proficient in html/css... I have a list of siblings
CSS newbie here. Strange thing is happening, I have gaps between links, and I
CSS code body { background-attachment: scroll; background-clip: border-box; background-color: #ececec; background-image: none; background-origin: padding-box;
I have a custom piece of Javascript which I would like to run on
Ideally, i would want the entire interface to have a custom styling that is
I have a css rule like this: .foo:active { background-position: 0px -382px; } .foo
I'm looking for a JQuery-style javascript/CSS control that will allow the user to drill
I am using JavaScript to dynamically add an element to the DOM. I want

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.