JSFiddle - React, Tailwind, and code Playground
by Jay Blanchard
HTML
<a href='' class='toggle-button switch-off'>Click Me</a>
<div id="color-list">Container Contents</div>
CSS
#color-list{display:none;}
JavaScript
var contentToggle = function(element){
if( $(element).hasClass('switch-off')){ // lowercase i on 'if'
$(element).toggleClass('switch-off switch-on');
$('#color-list').hide();
}else{
$(element).toggleClass('switch-on switch-off');
$('#color-list').show();
}
}
$('.toggle-button').click(function(e) {
e.preventDefault();
contentToggle( $(this) );
});