Initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
document.addEventListener("DOMContentLoaded", function(){
|
||||
// Fetch all the details element.
|
||||
const details = document.querySelectorAll("details");
|
||||
|
||||
// Add the onclick listeners.
|
||||
details.forEach((targetDetail) => {
|
||||
targetDetail.addEventListener("click", () => {
|
||||
// Close all the details that are not targetDetail.
|
||||
details.forEach((detail) => {
|
||||
if (detail !== targetDetail) {
|
||||
detail.removeAttribute("open");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user