Highlight highest value in table cell
I have this metod to highlight highest value in table cell:
- var max = 0;
- var bg = 0;
- $(this).find('.my-table').each(function () {
- $this = parseInt($(this).find('tbody tr:eq(1) td:eq(0)').text());
- if ($this > max)
- {
- max = $this;
- bg = $(this).find('tbody tr:eq(1) td:eq(0)');
- }
- });
- bg.addClass('highlight');
It kinda works but not as I would like.
If I have this values: 1, 2, 3, 4, 7,
8, 8...
then 8 is the largest but the problem is that only one is highlighted. I would like every one that has largest value to be highlighted: 1, 2, 3, 4, 7,
8,
8...
Could the function be modified to solve this? And if so, how?