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
Three things spring to mind:
:lastpseudo-element. That will match at most one element total, in this case the very last table cell in “stocktable”. Do you perhaps mean:last-childinstead?:eq(2)which will match the third element in the entire set only. Do you perhaps mean:nth-child(2)?$("#stocktable tr td.eq(2)).addClass...is missing and end quote; andTo further explain (1) imagine you have a table with 3 rows of 4 cells with an id of “mytable”. This code:
will colour the third element of the first row (
:eq()is zero-based) whereas:will colour the second cell in each row.
will colour the very last cell in the very last row but:
will colour the last cell in each row.