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