JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<p class="active">Duma 1</p>
<p class="inactive">Duma 1 - changed</p>
<p class="active">Duma 2</p>
<p class="inactive">Duma 2 - changed</p>
</body>
JavaScript
$(document).ready(function(){
// We hide the paragraphs with class = inactive.
$("p.inactive").css("display","none");
// When we click on paragraph element
$("p").click(function () {
$.do = $(this).toggle();
// We check the class to see what is it and make the SWITCH.
if ($(this).hasClass("active")) {
$.do;
$(this).next('.inactive').toggle();
}
else {
$.do;
$(this).prev('.active').toggle();
}
});
});