jQuery: How to calculate the maximal attribute value of all matched elements?

Just loop over them:

var maximum = null;

$('.a').each(function() {
  var value = parseFloat($(this).attr('x'));
  maximum = (value > maximum) ? value : maximum;
});

Leave a Comment