If the details
tag has an open
attribute, the summary
text will say "Close".
My attempt at changing the text:
if (jQuery("details").click().attr("open")) {
jQuery("summary").text("Close");
} else if (jQuery("details").click().attr("")) {
jQuery("summary").text("Show")
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<details class="description" open>
<summary class="">Show</summary>
<p class="">Description text</p>
</details>