tengo un problema. estoy usando javascript y siempre estoy tratando de hacer un código más rápido.
así que creo una aplicación que verifica la posición de los píxeles.
si su puntero de píxel (rojo) está en la posición de destino, el objetivo realiza una acción ... simplemente presione (t) para verlo hacia abajo
Pero cuando cruza el mosaico rojo en el bucle para crear muchos lugares, akk "si" no funciona.
Ojalá esté alerta cada vez que el rojo se lleva al azul.
¿Tiene algún disparador para hacer que el cheque colisione con el primer objeto con otro?
¿cómo hacer mucho si verificarse automatizado?
<body> </body> <script> //ok... trying again document.addEventListener('keydown', function(e) { if (e.keyCode == 84) { e.preventDefault(); check(); } }) var position = 0 let a = document.createElement("div") a.style.backgroundColor = "red" a.style.height = '1px' a.style.width = '1px' a.style.top = position a.style.position = "absolute" document.body.append(a) for (let index = 0; index < 10; index++) { let x = index //b = new b all the time let b = document.createElement("div") b.style.backgroundColor = "blue" b.style.height = '1px' b.style.width = '1px' b.style.position = "absolute" b.style.top = Math.floor(Math.random(10 - 0) * 100) document.body.append(b) //remember b = nem b on let all the time function check(){ a.style.top = position++ if (a.style.top === b.style.top ){ alert("its ok") } } } </script>ayuda