-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (19 loc) · 675 Bytes
/
app.js
File metadata and controls
21 lines (19 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let txt = document.querySelector('.txt'),
aText = document.createElement('div');
aText.classList.add('curText');
txt.textContent = '';
window.addEventListener('mousemove', event => {
if (event.target.closest('.pol')) {
aText.style.left = event.clientX + 15 + 'px';
aText.style.top = event.clientY + 15 + 'px'
aText.innerHTML = event.target.getAttribute('data-name');
document.body.append(aText);
} else if (!event.target.closest('.pol')) {
aText.remove()
}
});
window.addEventListener('click', event => {
if (event.target.closest('.pol')) {
txt.innerHTML = event.target.getAttribute('data-name');
}
})