-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
24 lines (21 loc) · 861 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const wrapper = document.querySelector('.wrapper');
const question = document.querySelector('.question');
const No = document.querySelector('.no');
const Yes = document.querySelector('.yes');
Yes.addEventListener('click', () => {
question.innerHTML = "Yes! you are an Idiot :)";
});
No.addEventListener('click', () => {
question.innerHTML = "No! you are an Idiot :)";
});
document.addEventListener('keydown', (event) => {
event.preventDefault();
});
No.addEventListener('mouseover', () => {
const wrapperRect = wrapper.getBoundingClientRect();
const NoRect = No.getBoundingClientRect();
const i = Math.floor(Math.random() * (wrapperRect.width - NoRect.width)) + 1;
const j = Math.floor(Math.random() * (wrapperRect.height - NoRect.height)) + 1
No.style.left = i + "px";
No.style.top = j + "px";
});