I'm currently developing a JavaScript with jQuery script that displays a div block when the countdown timer reaches zero.
Check out my code snippet:
<HTML>
<HEAD>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="./test.css" />
<script>
$(function () {
var count = 5,
countdown = setInterval(function () {
$("p.countdown").html(count);
if (count == 0) {
$("p.countdown").hide();
$("p#countblock").show();
clearInterval(countdown);
}
count--;
}, 1000);
});
$('#clickToHide').click(function() {
$("p#countblock").hide();
});
</script>
</HEAD>
<body>
<p id="clickToHide"> X </p>
<p class="countdown"></p>
<p id="countblock"> text to appear </p>
</body>
</HTML>
And here's how I styled it using CSS:
#countblock{
display:none;
width:200px;
height:50px;
position:absolute;
background-color:#f1f1f1;
}
The functionality seems to be working fine, but for some reason, clicking on "X" isn't hiding the countblock
. Can you help me identify where I went wrong and provide a solution?