Akash21 Akash21 - 5 months ago 12
HTML Question

I'm trying to make a square appear using a delayed timer but it's not appearing

Here is my stylesheet and code:

.shape{
height:200px;
width:200px;
background-color:#DD0A19;
display:none;
}


I am trying to make a game that tests users' reaction times to clicking the square, which disappears when clicked.

<body>
<p>Your time: <span id="timeTaken"></span></p>
<div class="shape" id="disappear"></div>
<script type="text/javascript">

var start = new Date().getTime();

function makeItemAppear () {
document.getElementById("disappear").style.display = "block";
start = new Date().getTime();
}

function appearAfterDelay () {
set.Timeout(makeItemAppear, 1000);
}

appearAfterDelay();

document.getElementById('disappear').onclick = function () {
document.getElementById("disappear").style.display = "none";
var end = new Date().getTime();
var timeTaken = (end - start)/1000;
document.getElementById("timeTaken").innerHTML = timeTaken + "s";
appearAfterDelay();

}
</script>

Answer

just delete the dot - '.' in set.timeout .

set.Timeout --> setTimeout