EugeneZheng:我第一题是 60% 不知出了什么差错,先贴出来再看看 function second(second) {
if (!second || second < 0) {
second = 0;
}
return {
day: Math.floor(second / (24 * 60 * 60)),
hour: Math.floor(second / (60 * 60)) % 24,
min: Math.floor(second / 60) % 60,
second: second % 60
};
}
function render(data) {
var countdown = document.getElementById('jsCountdown');
if (!countDown) {
throw '#jsCountdown not exists.';
}
var daySpan = countDown.children[0],
hourSpan = countDown.children[1],
minSpan = countDown.children[2],
secondSpan = countDown.children[3];
var renderText = function (elem, val, append) {
append || (append = '');
var paddedVal = (val < 10 ? '0' + val : '' + val);
elem.innerHTML = paddedVal + append;
}
if (!+data['day']) {
daySpan.classList.add('hide');
} else {
renderText(daySpan, data['day'], '天');
}
renderText(hourSpan, data['hour'], ':');
renderText(minSpan, data['min'], ':');
renderText(secondSpan, data['second']);
}
投递百度等公司10个岗位 >
0 点赞 评论 收藏
分享
投递搜狐等公司10个岗位 >
0 点赞 评论 收藏
分享
关注他的用户也关注了: