-- Apr 28 In-Class Exercise Thread
<!DOCTYPE html>
<html>
<head>
<title>Lab Exercise</title>
</head>
<body>
<div
id="jump"
style="color: black; font-size: 32px; position: absolute; top: 5in;"
onclick="jump();"
>
Jump!
</div>
<script type="text/javascript">
function jump(){
let height = 4.5;
let jumpStyle = document.getElementById("jump").style;
jumpStyle.color = "red";
jumpStyle.top = height + "in";
let interval = setInterval(() => {
height -= 0.5;
jumpStyle.top = height + "in";
}, 500)
let timeout = setTimeout(() => {
clearInterval(interval);
jumpStyle.top = "5in";
jumpStyle.color = "black";
}, 5000);
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Lab Exercise</title>
</head>
<body>
<div
id="jump"
style="color: black; font-size: 32px; position: absolute; top: 5in;"
onclick="jump();"
>
Jump!
</div>
<script type="text/javascript">
function jump(){
let height = 4.5;
let jumpStyle = document.getElementById("jump").style;
jumpStyle.color = "red";
jumpStyle.top = height + "in";
let interval = setInterval(() => {
height -= 0.5;
jumpStyle.top = height + "in";
}, 500)
let timeout = setTimeout(() => {
clearInterval(interval);
jumpStyle.top = "5in";
jumpStyle.color = "black";
}, 5000);
}
</script>
</body>
</html>