Documentos de Académico
Documentos de Profesional
Documentos de Cultura
DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
onClick="mostrarMensaje()"
> </div>
onClick="mostrarMensaje()"> </div>
<script>
document.getElementById("cuadrito").style.top= "400px";
document.getElementById("cuadrito").style.left= "10px";
window.addEventListener(
"keydown",
(event) => {
if (event.defaultPrevented) {
return;
switch (event.key) {
case "ArrowDown":
document.getElementById("resultado").innerHTML="abajo ";
document.getElementById("cuadrito").style.position="absolute";
case "ArrowUp":
document.getElementById("resultado").innerHTML="arriba ";
document.getElementById("cuadrito").style.position="absolute";
break;
case "ArrowLeft":
document.getElementById("resultado").innerHTML="izquierda ";
break;
case "ArrowRight":
document.getElementById("resultado").innerHTML="derecha ";
break;
case "Enter":
cambiarColor();
break;
case "Escape":
retornarColor();
break;
default:
event.preventDefault();
},
true,
);
function cambiarColor(){
document.getElementById("cuadrito").style.backgroundColor="red";
function retornarColor(){
document.getElementById("cuadrito").style.backgroundColor="blue";
document.getElementById("resultado").innerHTML="Mostrar resultado";
function mostrarMensaje(){
document.getElementById("resultado").innerHTML="11-1";
let intervalID2;
function mover(){
intervalID2= setInterval(mov,100);
}
function detener(){
clearInterval(intervalID2);
let j =20;
let jStr;
function mov(){
j=j+10;
jStr = parseInt(j,10);
document.getElementById("bolita").style.top= jStr+"px";
document.getElementById("mensaje").innerHTML= rect.top;
document.getElementById("mensajeBarra").innerHTML= rect2.top;
if( (rect.top > rect2.top -rect.height) && ((rect.left > rect2.left) && ( rect.left < (rect2.left +
rect2.width) ) ) ){
detener();
subirBolita();
function subirBolita(){
// aplicar lógica para subida ( funcion mov pero hacia arriba , dentro de otro timer)
// top + bolita
// left
function reiniciar(){
</script>
<style>
#cuadrito {
position: absolute;
background-Color:blue;
width:140px;
height:20px;
top: 100px;
left: 50px;
#bolita {
position: absolute;
background-Color:green;
width:20px;
height:20px;
top: 150px;
left: 150px;
</style>
</body>
</html>