Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Highlight highest number in a table

Have working code already, just needs tweaking



11:41 am on Oct 10, 2011 (gmt 0)

5+ Year Member

I had a table with 3 columns, Item Name, Price 1, Price 2 and I wanted to highlight the highest price, I got this working with a little helping hand.

I now need to change it so on one table row I have 3 items, so the layout would be:

Item 1, Price1, Price2 - Item 2, Price1, Price 2 - Item3, Price1, Price2.

What I'm trying to achieve is highlight the highest the highest price for each item. I've fiddled with the code I already have but cannot get it working, I'm hoping someone can point me in the right direction.

Here's what I have at the moment:

<script type='text/javascript'>
(function($) {
$.fn.max = function(callback) {
var max = null,
maxIndex = null;

this.each(function() {
var value = callback.call(this);
if (+value === value) {
if (!max || value > max) {
max = value;
maxIndex = $(this).index();

return max !== null ? this.eq(maxIndex) : $();

$('tr').each(function() {
$(this).children('td').max(function() {
var value = +$(this).text().substr(1);
if (!isNaN(value)) {
return value;
}).addClass('green bold');

Featured Threads

Hot Threads This Week

Hot Threads This Month