Yet another answer for those who don't want to use obsolete jQuery and those who loves functional javascript
[...document.getElementsByTagName("details")].forEach( (D,_,A) =>
D.addEventListener("toggle", E =>
D.open && A.forEach(d =>
d!=E.target && (d.open=false)
)
)
)
1
Demo 1
2
Demo 2
3
Demo 3