Reputation: 11
I need to make a timer in jQuery and after the timer end (time = 0) one-button becomes appear, where is my problem ??
<style>
.btn_repeat {
display: none;
}
</style>
my body
<p>
You'll be automatically redirected in <span id="count">5</span> seconds...
</p>
<button class="btn_repeat">resend</button>
j query code
<script type="text/javascript">
window.onload = function() {
(function() {
var counter = 5;
setInterval(function() {
counter--;
if (counter >= 0) {
span = document.getElementById("count");
span.innerHTML = counter;
}
// Display 'counter' wherever you want to display it.
if (counter === 0) {
clearInterval(counter);
$(".btn_repeat").display = "block";
}
}, 1000);
})();
};
</script>
Upvotes: 0
Views: 110
Reputation: 89139
Do not mix jQuery and native JavaScript methods. Use .show()
to display a hidden element.
$('.btn_repeat').show();
Alternatively, you can use the .css()
method to set CSS properties of elements.
$('.btn_repeat').css("display", "block");
Upvotes: 1