This is the jQuery script I found and used:
<script>
jQuery(“.toc-container-close”).click(function() {
jQuery(this).closest(“.toc-container-close”).toggleClass(“.toc-container-open”);
});
</script>
This is the css I used:
.toc-container.close {
width: 35px;
height: 35px!Important;
overflow: hidden;
border: solid 2px #ddd;
background: #fff;
}
.toc-container-open {
width: auto;
height: auto;
overflow: auto;
border: solid 2px #ddd;
background: #fff;
}
.toc-container-close is the css class of the Elementor section the WPJoli shortcode is in. On default it is a closed round button:
On click on the round button, or any of the links that are inside the .toc-container-open the class is every time toggled between .toc-container-close and .toc-container-open.
Making it this way gave me more control to put other things in the TOC container.
Not exactly like you said, but the idea is the same.