-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
23 lines (21 loc) · 1014 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const hovOb = document.getElementById("objectj"),
locateE = document.getElementById("location");
let xPo;
let yPo;
xPo = Math.floor(Math.random() * ((document.querySelector("#box").offsetWidth - hovOb.offsetWidth) + 1) + 1);
yPo = Math.floor(Math.random() * ((document.querySelector("#box").offsetHeight - hovOb.offsetHeight) + 1) + 1);
hovOb.style.top = `${yPo}px`;
hovOb.style.left = `${xPo}px`;
let r = setInterval(() => {
xPo = Math.floor(Math.random() * ((document.querySelector("#box").offsetWidth - hovOb.offsetWidth) + 1) + 1);
yPo = Math.floor(Math.random() * ((document.querySelector("#box").offsetHeight - hovOb.offsetHeight) + 1) + 1);
hovOb.style.top = `${yPo}px`;
hovOb.style.left = `${xPo}px`;
}, 100)
hovOb.addEventListener("click", () => {
clearInterval(r);
hovOb.style.cssText = "background: #33FF06; box-shadow: 0 0 50px 0 #33FF06;";
locateE.innerHTML = `Congratulations! <a href="/">Reload To Try Again</a>`;
hovOb.style.top = `${yPo}px`;
hovOb.style.left = `${xPo}px`;
})