homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Highlight highest number in a table
Have working code already, just needs tweaking

Msg#: 4372674 posted 11:41 am on Oct 10, 2011 (gmt 0)

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');


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved