我第一题是 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']); }
点赞 3

相关推荐

西南山:哥,你的技能是在报菜单吗
点赞 评论 收藏
分享
牛客网
牛客企业服务