I'd like to have a button that opens the closest details element (above button) without using ID. I've tried variations of the following code and search every thread but can't figure it out
function openDetail(detailsElement) {
detailsElement.setAttribute("open");
}
<details>
<summary>Summary 1</summary>
Test 1
</details>
<button onclick="openDetail(closest)">button</button>
<details>
<summary>Summary 2</summary>
Test 2
</details>
<button onclick="openDetail(closest)">button</button>