-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamic.js
33 lines (29 loc) · 1.4 KB
/
dynamic.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
25
26
27
28
29
30
31
32
33
const toggleVisibility = (id) => {
const element = document.querySelector(id);
const currentDisplay = element.style.display;
element.style.display = currentDisplay == "block" ? "none" : "block";
};
document.addEventListener("DOMContentLoaded", function (event) {
const hoverfield = document.querySelector("#hoverfield");
hoverfield.addEventListener("mouseover", () =>
toggleVisibility("#linkpopup")
);
hoverfield.addEventListener("mouseout", () => toggleVisibility("#linkpopup"));
const range = document.querySelector("#range");
const output = document.querySelector("#phone");
range.addEventListener ("input", function () {
output.value = this.value.toString().replace(/^(\d{3})(\d{3})(\d{3})/, '$1-$2-$3');
});
const myBtn = document.querySelector("#randy");
const myBtn2 = document.querySelector("#randyno");
const name = document.querySelector("#name");
const nextY = document.querySelector("#next");
nextY.innerHTML = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(Math.floor(Math.random() * 52));
myBtn.addEventListener("click", () => {
name.innerHTML += nextY.innerHTML;
nextY.innerHTML = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(Math.floor(Math.random() * 52));
});
myBtn2.addEventListener("click", () => {
nextY.innerHTML = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(Math.floor(Math.random() * 52));
});
});