Comparison sometimes works and sometimes not

Comparison sometimes works and sometimes not

Hi!

Can anybody tell mee how the comparison in the script below can sometimes work and sometimes not? It just told me that 355 > 250, but also that 37 > 3587. How can that be possible?

<script>
$(document).ready(function() {
    $("form#form-voorraadlijst input[type='number']").focusout(function() {
        if ($(this).attr('value') > $(this).attr('max')) {
            alert ($(this).attr('value') + ">" + $(this).attr('max'));
        }
    });
});
</script>

Hope to hear quickly from you guys.
Thanks in advance.