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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:04:57+00:00 2026-05-13T09:04:57+00:00

I need some help with this I am trying to do this if(perc>0){ alert(‘change

  • 0

I need some help with this

I am trying to do this

if(perc>0){
alert('change backgroundcolor and textcolor');
$('#stocktable tr td:last').addClass('stockhigher');

}

but It does not work on a tablecell

I also try’d to set the selector like this

$('#stocktable tr td:eq(2)).addClass...
$('#stocktable tr td.percentage').addClass...

nothing!

it does work on the table itself or a tablerow like

$('#stocktable tr')

am I missing something here?

thanks, Richard

  • 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-13T09:04:57+00:00Added an answer on May 13, 2026 at 9:04 am

    Three things spring to mind:

    1. You’re using the :last pseudo-element. That will match at most one element total, in this case the very last table cell in “stocktable”. Do you perhaps mean :last-child instead?
    2. You’re using :eq(2) which will match the third element in the entire set only. Do you perhaps mean :nth-child(2)?
    3. $("#stocktable tr td.eq(2)).addClass... is missing and end quote; and
    4. There is nothing wrong with what you’re doing. What precisely isn’t working? Perhaps it’s not formatting that can be applied to a table cell.

    To further explain (1) imagine you have a table with 3 rows of 4 cells with an id of “mytable”. This code:

    $("#mytable td:eq(2)").css("background", "yellow");
    

    will colour the third element of the first row (:eq() is zero-based) whereas:

    $("#mytable td:nth-child(2)").css("background", "yellow");
    

    will colour the second cell in each row.

    $("#mytable td:last").css("background", "yellow");
    

    will colour the very last cell in the very last row but:

    $("#mytable td:last-child").css("background", "yellow");
    

    will colour the last cell in each row.

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

Sidebar

Related Questions

I really need some help with this as I have been trying to fix
I am trying to figure this one out, but I need some help. I
I need some help trying to come up with a way to set this
I need some help wrapping my head around this. I am trying to develop
I need some help with this. I am trying to make a mini game
I need some help figuring this out. I am trying to create a function
I need some help about optimisation. I am trying to improve this open-source game
i need some help with this, i'm trying to generate some html with javascript,
I need some help with this showDocument in my jnlp aplication. I trying to
Need some help with this problem in implementing with XSLT, I had already implemented

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.