Your html is invalid as you are having duplicate ids for trs.
Below code can handle duplicate ids
- $(function(){
-
var ids = new Array();
-
$('#example tbody tr').each(function(){
-
ids.push(parseInt($(this).attr('id'), 10));
- });
-
var maxId = Math.max.apply(null, ids);
-
$('#example tbody tr[id="'+maxId+'"]').addClass('highlight');
- });
Here is your updated fiddle http://jsfiddle.net/s7kms16t/1/