JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div id="block1"></div>
<div id="block2"></div>
<div id="button"></div>
</div>
CSS
#container{
width: 400px;
position: relative;
}
#block1{
height: 100px;
background-color:lightgreen;
}
#block2{
height: 100px;
background-color:lightblue;
}
#button {
position: absolute;
top: 110px;
}
JavaScript
$(function () {
var text = 'Свернуть';
var text2 = 'Развернуть';
$('#button').html(text);
$('#button').click(function (){
if($(this).html()==text) {
$('#button').html(text2);
$(this).animate({top: '70'}, 500);
}
else {
$('#button').html(text);
$(this).animate({top: '110'}, 500);
}
$("#block2").slideToggle();
});
});