16,874
个编辑
LLWiki正在建设中,欢迎加入我们!
小 |
小 |
||
window.addEventListener('load', function () {
var timeObj = {};
const fromNow = function (
const now = moment()
before = ele.children[1],
const monthsHave31Days = [0, 2, 4, 6, 7, 9, 11]; // 月份从0开始▼
after = ele.children[2],
isBefore = then.isBefore(now),
let year = isBefore ? now.year() - then.year() : then.year() - now.year(),
month = isBefore ? now.month() - then.month() : then.month() - now.month(),
}
if (hour > 0) {
result += `<span class="countdown-num">${hour}</` + 'span>
} else if (result !== "") {
result += `<span class="countdown-num">${0}</` + 'span>
}
if (minute > 0) {
result += `<span class="countdown-num">${0}</` + 'span>秒';
}
before.innerHTML = before.innerHTML.replace("$1", result.replace(/(\d) /g, "$1"));
after.style.display = "none";
else {
afet.innerHTML = after.innerHTML.replace("$1", result.replace(/(\d) /g, "$1"));
before.style.display = "none";
}
};
const run = () => {
document.querySelectorAll(".countdownNode:not(.disabled)").forEach( fromNow(ele)
▲ });
};
document.querySelectorAll(".countdownNode").forEach((ele) => {
|