-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
21 lines (17 loc) · 897 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
window.addEventListener("collapsible-content-open", ({ target, detail }) => {
const button = document.querySelector(`[data-collapsible=${target.id}]`);
button.textContent = detail ? "close" : "open";
button.setAttribute("aria-expanded", detail);
});
window.addEventListener("click", ({ target: { dataset } }) => {
if (dataset.collapsible) {
document.getElementById(dataset.collapsible).toggleAttribute("open");
}
});
const addButton = document.getElementById("add-dynamic-content");
addButton.addEventListener("click", () => {
const p = document.createElement("p");
p.innerText =
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer rutrum, orci vestibulum ullamcorper ultricies, Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer rutrum, orci vestibulum ullamcorper ultricies";
document.getElementById("collapsible-2").appendChild(p);
});