I need to calculate percentage of some not equal number. I am counting percentage using parseFloat
, but it's work only for rounded numbers like 2000, or 200 which gives me 20% and 2%. I's not working for 2200 or 220 to reach 2.2% or 22.2%.
$(document).on('keyup', '.js-baOfferPrice.percentage', function(e) {
var s, target = $(e.target);
var p = $('.js-baAppPrice').text();
s = parseFloat(parseInt(target.val(), 10) * 100) / parseInt(p, 10);
target.val() === "" ? target.val("") : target.val(Math.round(s).toFixed(0));
});
Can anybody help?