Math 查找反向百分比

Math 查找反向百分比,math,Math,我有一个函数,它根据在div.days due中找到的数字设置引导进度条。它工作正常,但进度条的宽度与我想要的相反 如何反转progBarValue编号 function daysUntil(year, month, day) { var now = new Date(), dateEnd = new Date(year, month - 1, day), // months are zero-based days = (dateEnd - now) / 1000/6

我有一个函数,它根据在div.days due中找到的数字设置引导进度条。它工作正常,但进度条的宽度与我想要的相反

如何反转progBarValue编号

function daysUntil(year, month, day) {
  var now = new Date(),
      dateEnd = new Date(year, month - 1, day), // months are zero-based
      days = (dateEnd - now) / 1000/60/60/24;   // convert milliseconds to days

  return Math.round(days);
}

// find percentage to due date
$('#paging1 ul li').each(function () {

    var monthDue = $(this).find('.month').text();
    var dayDue = $(this).find('.day').text();
    var yearDue = $(this).find('.year').text();

    $(this).find('.days-due').text(daysUntil(yearDue, monthDue, dayDue));

    // progress bar
    // find number of days until due date
    var progBarValue = $(this).find('.days-due').text();
    // limit days due to no more than 100%
    progBarValue = progBarValue > 100 ? 100 : progBarValue;
    // set progress bar width
    $(this).find('.bar').width(progBarValue +"%");

});

嗯,
$(this).find('.bar').width((100-progBarValue)+“%”)

从100中减去当前百分比。也就是说,如果你完成了10%,你就没有完成90%。这就是百分比的意思。这是一道数学题,不是一道编程题。