-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.js
26 lines (23 loc) · 956 Bytes
/
sample.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
function addDynamicJS() {
const dyn = document.createElement("p");
const hr = document.createElement("hr");
dyn.classList.add("dynamic-css");
dyn.innerHTML = `Added by JS <b>file</b> on <b>click</b> with <b>class=dynamic-css</b> defined by <b>CSS file</b>`;
document.body.appendChild(hr);
document.body.appendChild(dyn);
}
window.addEventListener("load", () => {
const timeout = setTimeout(() => {
const hr = document.createElement("hr");
const used = document.createElement("p");
used.classList.add("used-css");
used.innerHTML = `Added by JS <b>file</b> on <b>load</b> + 10ms with <b>class=used-css</b> defined by <b>CSS file</b>`;
const button = document.createElement("button");
button.onclick = addDynamicJS;
button.innerHTML = `Add Dynamic by JS file`;
document.body.appendChild(hr);
document.body.appendChild(used);
document.body.appendChild(button);
clearTimeout(timeout);
}, 10);
});