我有这个倒数计时器,一旦达到0,我希望它显示div,当前设置为:display: none;
以下是倒计时代码:
function startTimer(duration, display) {
var timer = duration,
minutes, seconds;
setInterval(function () {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = minutes + " min " + seconds + " sec";
if (--timer < 0) {
display.textContent = "Yay, It's done!"
}
}, 1000);
}
window.onload = function () {
display1 = document.querySelector('#time1');
startTimer(1 * 5, display1);
};
在这一部分:
if (--timer < 0) {
display.textContent = "Yay, It's done!"
在显示该文字后,我怎样才能让它显示隐藏的div?
答案 0 :(得分:1)
您可以将其显示设置为阻止。
elementYouWantToShow.style.display = 'block';
答案 1 :(得分:1)
普通JS
document.getElementById('myID').style.display = "block";
JQuery的
$('#myID').fadeIn();