Fix JS bug

This commit is contained in:
MatthiasSaihttam 2021-09-01 20:06:15 -04:00
parent 61c2e018d0
commit a611fc1789
1 changed files with 17 additions and 15 deletions

View File

@ -61,21 +61,23 @@
for (let el of els) {
const extended = el.querySelector(".extended");
//Hide extended text
extended.classList.add("hidden");
//Add button to show extended text
if (extended.childNodes.length) {
const main = el.querySelector(".main");
const showMoreButton = document.createElement("button");
showMoreButton.appendChild(document.createTextNode("Show More"));
showMoreButton.classList.add("show-more");
showMoreButton.addEventListener("click", evt => {
// Remove ourself
showMoreButton.parentNode.removeChild(showMoreButton);
// Show the extended text
extended.classList.remove("hidden");
})
main.appendChild(showMoreButton);
if (extended) {
//Hide extended text
extended.classList.add("hidden");
//Add button to show extended text
if (extended.childNodes.length) {
const main = el.querySelector(".main");
const showMoreButton = document.createElement("button");
showMoreButton.appendChild(document.createTextNode("Show More"));
showMoreButton.classList.add("show-more");
showMoreButton.addEventListener("click", evt => {
// Remove ourself
showMoreButton.parentNode.removeChild(showMoreButton);
// Show the extended text
extended.classList.remove("hidden");
})
main.appendChild(showMoreButton);
}
}
}