Here is my code.
Same concept, just a bit shorter.
$('details').click(function (event) { $('details').not(this).removeAttr("open"); });