JSFiddle - React, Tailwind, and code Playground
HTML
<div id ="toggle_template">This is a section header</div>
<div id="template">
Junk to show hide on click
</div>
JavaScript
$('#toggle_template').css('cursor', 'pointer').append(' (click to view)').click(function() {
$('#template').toggle(500);
$('#toggle_template').html(function(i, html) {
if (html.indexOf(' (click to view)') > 1) {
return html.replace(' (click to view)', ' (click to close)')
}
return html.replace(' (click to close)', ' (click to view)')
});
});