-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
19 lines (15 loc) · 713 Bytes
/
main.js
File metadata and controls
19 lines (15 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const wrapper = document.querySelector('.wrapper');
const question = document.querySelector('.question');
const yesBtn = document.querySelector('.yes-btn');
const noBtn = document.querySelector('.no-btn');
const wrapperRect = wrapper.getBoundingClientRect();
const noBtnRect = noBtn.getBoundingClientRect();
yesBtn.addEventListener('click', () => {
question.innerHTML = 'Thanks, we will be making 1 billion kids :)';
});
noBtn.addEventListener('mouseover', () => {
const i = Math.floor(Math.random() * (wrapperRect.width - noBtnRect.width)) + 1;
const j = Math.floor(Math.random() * (wrapperRect.height - noBtnRect.height)) + 1;
noBtn.style.left = i + 'px';
noBtn.style.top = j + 'px';
});