我有一个函数可以根据在 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 +"%");
});