You can do it by using jquery, add the following script in phtml file.
<script>
require(['jquery', 'jquery/ui'], function($){
$(".class of your nav button").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
});
</script>
use your nav button class like $(".nav_btn")
or
you can use following code in success event of ajax
$("html, body").animate({ scrollTop: 0 }, "slow");
or make a function and call the function on click of the button
<script>
function movetotop(){
require(['jquery', 'jquery/ui'], function($){
$("html, body").animate({ scrollTop: 0 }, "slow");
}
</script>
and call this function like <a class ="nav_btn" href="#" onclick="movetotop()" ></a>
write the script outside of the file that is updating on ajax request