Last active
December 11, 2022 12:16
-
-
Save cballenar/89be83d0625877ed9fee2a6b337e71eb to your computer and use it in GitHub Desktop.
Revisions
-
cballenar revised this gist
Dec 11, 2022 . No changes.There are no files selected for viewing
-
cballenar revised this gist
Dec 11, 2022 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,15 +2,15 @@ * Toggle Summary Message. * Changes the content of a details' summary to indicate whether clicking it * will open or close it. Assumes the <summary> lies directly under the * <details> tag and contains `data-message-open` and `data-message-close` * attributes with the respective values for each case. * * @param {Event} event */ function toggleSummaryMessage(event) { const summary = event.target; summary.innerText = summary.parentElement.open ? summary.dataset.messageOpen : summary.dataset.messageClose; } // call for all summaries const summaries = document.querySelectorAll('details summary'); summaries.forEach((detail)=>detail.addEventListener('click',toggleSummaryMessage)); -
cballenar created this gist
Dec 11, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ /** * Toggle Summary Message. * Changes the content of a details' summary to indicate whether clicking it * will open or close it. Assumes the <summary> lies directly under the * <details> tag. * * @param {Event} event */ function toggleSummaryMessage(event) { const summary = event.target; summary.innerText = summary.parentElement.open ? summary.dataset.messageOpen : summary.dataset.messageClose; } // call for all summaries const summaries = document.querySelectorAll('details summary'); summaries.forEach((detail)=>detail.addEventListener('click',toggleSummaryMessage));