JSFiddle - React, Tailwind, and code Playground
HTML
<DIV ID="Wrapper">
my content
</DIV>
CSS
#Wrapper {
float: left;
width: 700px;
height: 1400px;
background-color: red;
}
JavaScript
$(document).ready(function() {
$("#Wrapper").click(function () {
var th = $(this);
if (!th.hasClass('down')) {
console.log("ret");
$('html,body').stop(true).animate({
scrollTop: th.height()
}, 1000, function() {
th.addClass('down');
//$('body').scrollTop(th.height());
});
} else {
console.log("sdffsdsff");
$('html,body').stop(true).animate({
scrollTop: th.get(0).offsetTop
}, 1000, function() {
th.removeClass('down');
//$('body').scrollTop(th.scrollTop());
});
}
});
});