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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:28:30+00:00 2026-05-26T08:28:30+00:00

I need a jQuery script that can change color on all td if it

  • 0

I need a jQuery script that can change color on all td if it contain a onClick that contain “BG5”.
It need to work on IE7. I have tried $(“a:contains(‘BG5’)”).css(“background”,”#F6CED8″);

Is this possible?

They TD get the effect by a push on buttom

    <tr bgcolor='#F2F2F2'>
    <td>2011-04-18</td>
    <td>a</td>
    <td>a</td>
    <td align="center"><a href="#" onClick="edit('BG5')"><img src="../img/icon/skruenogle.png" border=0 alt="Delete corr"></A>
    <td align="center"><a href="#" onClick="disregard('BG5')"><img class="click" src="../img/icon/redcross.png" border=0 alt="Delete corr"></A></td>
</tr>

<tr bgcolor='#FFFFFF'>
    <td>2011-04-18</td>
    <td>a</td>
    <td>a</td>
    <td align="center"><a href="#" onClick="edit('1A1')"><img src="../img/icon/skruenogle.png" border=0 alt="Delete corr"></A>
    <td align="center"><a href="#" onClick="disregard('1A1')"><img class="click" src="../img/icon/redcross.png" border=0 alt="Delete corr"></A></td>
</tr>
  • 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-26T08:28:31+00:00Added an answer on May 26, 2026 at 8:28 am

    If I’ve understood you correctly, what you’re trying to do is change the background colour of every tr element that contains an a tag which has the string “BG5” in an attribute named onClick.

    If that’s along the right lines, try something like this:

    $("a").filter(function() {
        if($(this).attr("onClick")) {
            return $(this).attr("onClick").indexOf("BG5") !== -1; 
        }
    }).closest("tr").css("background-color", "blue");
    

    Here’s a working example using your HTML and the above jQuery. Basically what that does is get all the a elements, filter them so we are left with only those which contain the string “BG5” in the onClick attribute, gets the closest tr element to those, and sets the background colour.

    An important thing to note would be that the attr method is case sensitive, so you’ll want to make sure you are consistent with your HTML!

    On a separate note, you really shouldn’t be using the bgcolor attribute, as it’s deprecated. CSS should always be used instead. Also, there’s a couple of td elements which have not been closed in the code in your question. That may just be a typo in the question, but worth a mention just in case!

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

Sidebar

Related Questions

I need a jquery script section that checks to see if the first digit
I have written a simple jQuery script that changes the hash tag of a
I have a PHP script that generates a list of places and I need
Need your help, trying to change this script: https://github.com/MrHus/jquery-monthly-ical To load external JSON data
I have a jquery script that collects data from different sites and saves it
I need some help with jQuery script again :-) Just trying to play with
I need help getting a Grease Monkey with JQuery Script to run on a
I am writing a greasemonkey script. The site is using jquery, i need a
I have been using mootools for a year now. I need to use jquery
I need to limit the jquery ui date picker to only have future Tuesdays

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.