Fix JS bug
This commit is contained in:
parent
61c2e018d0
commit
a611fc1789
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue