我正在写 jquery,如果超过 730 天,我需要更改颜色......在 730 到 183 天之间......等等。如果我的 if else 语句有问题,它在我的页面上不起作用?这是所有的 jquery,但我只需要 if/else 部分的帮助。我对此很陌生,任何帮助都很棒。
$(document).ready(function () {
'use strict';
var monthNames = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ],
dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
newDate = new Date();
$('#safetyRecord').hide();
$('#today').text(dayNames[newDate.getDay()] + "," + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getDate() + "," + ' ' + newDate.getFullYear());
$('#checkRecord').click(function () {
var dateOfLastAccident = new Date($('#dateOfLastAccident').val());
var today = new Date(),
daysSinceLastAccident = Math.floor((today.getTime() - dateOfLastAccident.getTime()) / (25 * 60 * 60 * 1000));
$('#daysSinceLastAccident').text(daysSinceLastAccident);
$('#safetyRecord').show();
if (daysSinceLastAccident >= parseInt(730)){
{
$('#safetyRecord').addClass('great');
}
else if (daysSinceLastAccident >=730<=183)
{
$('#safetyRecord').addClass('good');
}
else if (daysSinceLastAccident >=183<=60)
{
$('#safetyRecord').addClass('.marginal');
}
else if (daysSinceLastAccident >=60<= 14)
{
$('#safetyRecord').addClass('.poor');
}
else (daysSinceLastAccident < 14)
{
$('#safetyRecord').addClass('.disaster');
}
});
});