$.each(curr_string, function() { if ($(this).attr('price') != 0) { price *= parseFloat($(this).attr('price')); } });