[ Prev ]
2021-05-03

-- 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>

-- Apr 28 In-Class Exercise Thread
<!DOCTYPE html> <html> <body>
	<div style="font-size: 32px; color: black" onclick="move()">Jump!</div>
	
	<script>
		function move() {
				setTimeout(function(){ 
					var myElement = document.getElementById("myJump");
					myElement.style.bottom = "0.5in";
					myElement.style.color = "red";}, 
					5000);
			}
	</script>
</body> </html>
<!DOCTYPE html> <html> <body> <div style="font-size: 32px; color: black" onclick="move()">Jump!</div> <script> function move() { setTimeout(function(){ var myElement = document.getElementById("myJump"); myElement.style.bottom = "0.5in"; myElement.style.color = "red";}, 5000); } </script> </body> </html>
X