JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" class="show-hide hide">Click me to toggle</a>
<div class="content">
¡¡Content!!
</div>
JavaScript
function initShowHideContent(){
if($('a.show-hide').length){
$('a.show-hide').each(function(){
if($(this).hasClass('hide')){
$(this).next().hide();
}
});
$('a.show-hide').click(function(){
$(this).next().toggle();
if($(this).hasClass('hide')){
$(this).removeClass('hide').addClass('active');
}else{
$(this).removeClass('active').addClass('hide');
}
return false;
});
}
}
initShowHideContent();