Welcome to WebmasterWorld Guest from 23.21.38.201

Forum Moderators: open

Jquery highlight highest number

   
4:14 pm on Aug 3, 2011 (gmt 0)



I'm trying to highlight the highest number on each row or a table. I posted the question elsewhere and they provided the following code which works on jsFiddle.net but I can't get it working


<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) : $();
};
}(jQuery));

$('tr').each(function() {
$(this).children('td').max(function() {
var value = +$(this).text().substr(1);
if (!isNaN(value)) {
return value;
}
}).addClass('highlight');
});
</script>


I can see that the code works, I imagine it's me missing something when putting the code into my page, hopefully someone can point out what I'm doing wrong.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month