Style row based on column value = 0

I'm trying to style a table row if the first column value is 0 -- without success.

My code below works if the column value contains a 0 but this also styles the row if the value is 20, 102, 300 etc -- which is not what I want:

<script type="text/javascript">
$(document).ready(function(){
$('tbody tr td(0):contains("0")').parent().addClass('blu');			
});
</script>

Open in new window


How to I change the contains("0") to match only exactly 0 and not other values containing one or more 0 digits?
ShanghaiDAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zappafan2k2Commented:
How about this:
<script type="text/javascript">
$(document).ready(function(){
    $('tbody tr td(0)').each(function() {
        if ($(this).text() == '0') {
            $(this).parent().addClass('blu');
            }
    }
});
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShanghaiDAuthor Commented:
Thanks for pointing me in the right direction!

Don't know why, but td(0) doesn't work for me on the .each(function() {} but I did get it to work by using td:nth-child(1) instead:

$('tbody tr td:nth-child(1)').each(function() {

Open in new window


Also, I had to add ); to your final closing:

    });
});
</script>

Open in new window

0
zappafan2k2Commented:
Oops, glad you caught that.  Glad it worked.
0
ShanghaiDAuthor Commented:
Minor changes in syntax were needed to complete the solution, but most of the guidance came from the initial suggestion.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.