How to implement scrolling of the page up to coordinate a specific item?

How to implement scrolling of the page up to coordinate a specific item?
It is necessary when you press the button, prosquality her up to the boundary of the specified block (i.e. the coordinate unit/his position, I do not know as correctly).

Tried option
jQuery(document).ready(function(){

 // when you click on the element
$("element").click(function(){

 // define the height of the screen
 var screenHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
 // define the coordinate of the top corner of the div to the bottom which will scroll
 var blockTopPosition = document.querySelector('block').offsetTop;
 // define the height of a div to the bottom which will scroll
 var blockHeight = document.querySelector('block').offsetHeight;
 // define the coordinate of the lower boundary of the div to which you want to scroll
 var blockBottomPosition = blockTopPosition + blockHeight - screenHeight;
 // scrollen using scrollTop to the coordinate of the bottom border div and use this action
 $('body').animate({"scrollTop":blockBottomPosition},'slow'); 

});

});

But the result is a negative number, which leads to failure (when you replace the positive - working curve)
June 14th 19 at 18:13
1 answer
June 14th 19 at 18:15
Solution
Everything is much easier

$('element').on('click', function(){
 $('html, body').animate({
 scrollTop: $('target').offset().top
 }, 500);
});

Find more questions by tags JavaScript