JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>1-1</li>
<li>1-2</li>
</ul>
<ul>
<li>2-1</li>
<li>2-2</li>
</ul>
<div></div>
JavaScript
$("ul").each(function () {
$('div').append($("<button></button>")
.append($(this).clone()).click(function () {
$(this "ul").toggle();
})
);
$(this).remove().html();
});