# Counting list items in each TD with jQuery?

**URL:** <https://forum.kirupa.com/t/counting-list-items-in-each-td-with-jquery/326461>\
**Category:** web dev\
**Created:** [December 16, 2011, 1:37am UTC](https://forum.kirupa.com/t/counting-list-items-in-each-td-with-jquery/326461 "2011-12-16T01:37:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kozmo02](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kozmo02](https://forum.kirupa.com/u/kozmo02)\
**Post date:** [December 16, 2011, 1:37am UTC](https://forum.kirupa.com/t/counting-list-items-in-each-td-with-jquery/326461/1 "2011-12-16T01:37:21Z")

</div>

Within each TD of the retailers div there is a UL, what I am trying to do is determine how many list items exist in each individual TD, if there is more than 1 list item I need to style it a specific way, as you can see below, however, when trying this code it applies the CSS to every LI, I am not sure where I am going wrong?

```auto

    $('#retailers tr').each(function()
    {
        $.each(this.cells, function()
        {
            var countLI = $("ul.links").children().length;
            
            if(countLI + ":gt(1)")
            {
                $("ul.links li").css("background-color", "yellow");             
            }                               
        });
    });

```
