Is it possible to modify the script smooth scrolling?

There is a script for a smooth scroll triggered from an href:
$(".slowly").on("click", function (event) {
 /*Cancel default processing for clicking the link.*/
event.preventDefault();
 /*Pick up the block ID from the href attribute.*/
 var id = $(this).attr('href'),
 /*Find out the height from the beginning page of the block referenced by the anchor.*/
 top = $(id).offset().top;
 /*Use the transition to distance - top for 1000ms.*/
 $('body,html').animate({scrollTop: top}, 1200);

Is it possible to make so that the button is triggered on an anchor the same function as the link -
<form action="#tutorial" class="slowly">
 <button class="button slogan-button hvr-bounce-in">
<span>Go!</span>
</button>
</form>

Only the href in the script, was replaced by action - smooth transition to the id of the block, tried in the script, just change the href action. Not working
UPD: I'm trying to do in order not to produce extra css code, as the buttons are the same, and styles spelled out for everyone, I would like to do a link with registration under this button
June 5th 19 at 21:28
3 answers
June 5th 19 at 21:30
Solution
<button class="slowly" data-target="some_id">Take me there but slowly</button>


$(".slowly").on("click", function (event) {
 /*Cancel default processing for clicking the link.*/
event.preventDefault();
 /*Pick up the block ID from the href attribute.*/
 var id = $(this).attr('href') || $(this).attr('data-target');
 /*Find out the height from the beginning page of the block referenced by the anchor.*/
 var top = $(id).offset().top;
 /*Use the transition to distance - top for 1000ms.*/
 $('body,html').animate({scrollTop: top}, 1200);
Thank you, a great option - Zola.Rempel79 commented on June 5th 19 at 21:33
June 5th 19 at 21:32
Make the button just link to <a href="#block">Go</a> and make her the style similar like button
UPD: I'm trying to do in order not to produce extra css code, as the buttons are the same, and styles spelled out for everyone, I would like to do a link with registration under this button - Zola.Rempel79 commented on June 5th 19 at 21:35
June 5th 19 at 21:34
var id = $(this).attr('href') || $(this).attr('action'),


https://jsfiddle.net/c6rmegtx/

Find more questions by tags CSSLayoutJavaScriptHTML