JSFiddle - React, Tailwind, and code Playground
by Softlink
HTML
<h2 class="acc_trigger"><a href="#">Свернуть каталог статусов</a></h2>
<div class="acc_container">
<div class="block">
<p>текст в спойлере </p>
</div>
</div>
CSS
h2.acc_trigger {
display: inline-block;
padding: 5px 0px;
font-size: 14px;
font-weight: normal;
border-bottom: 1px dashed #fff;
/* Old browsers */
}
h2.acc_trigger a {
color: #000;
text-decoration: none;
display: block;
padding: 0 20px 0 0px;
background: url(images/spoiler.png) no-repeat 100% 5px;
}
h2.active{
background: none; /* Old browsers */
}
h2.active a {background-position: 0 -23px; color: blue;}
.acc_container {
display: none;
margin: 0 0 5px;
padding: 0;
overflow: hidden;
font-size: 14px;
color: #484848;
}
.acc_container .block {
padding: 0px;
}
JavaScript
$(document).ready(function(){
$('.acc_container').hide();
$('.acc_trigger').click(function(){
if( $(this).next().is(':hidden') ) {
$('.acc_trigger').removeClass('active').next().slideUp();
$(this).toggleClass('active').next().slideDown();
}
return false;
});
});