'How can I select the first table cell with specific content (cells in different rows)? [duplicate]

I have a table with several cells with the same content. I would like just to select the first one and do some CSS changes.

The cells are not in the same row (tr)

What I have so far is:

jQuery('td:contains("Februar")').css('font-weight', 'bold');

That works for all the td's with 'Februar'. I tried to select just the first one with :first, but that doesn't seem to work.



Solution 1:[1]

All of the lines below will work.

jQuery('td:contains("Februar")')[0].style.fontWeight = 'Bold'; or jQuery('td:contains("Februar")').first().css('font-weight', 'bold'); or jQuery('td:contains("Februar")').eq(0).css('font-weight', 'Bold'); or jQuery('td:contains("Februar"):first').css('font-weight', 'bold');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1