$('.offers-number').bind('input propertychange', function (a, b) { var value = $(this).val() if (!value || isNaN(value)) $(this).removeClass("active").val("") else $(this).addClass("active") total() });