jquery scroll to specific div

Solutions on MaxInterview for jquery scroll to specific div by the best coders in the world

showing results for - "jquery scroll to specific div"
Sofia
18 Jan 2019
1/* HTML LAYOUT */
2<div class="my-div" id="login-section"></div>
3/* JQUERY Code*/
4$(".my-menu-link").click(function () {
5  $("html, body").animate({
6    scrollTop: $("#" + $(this).attr("id")).offset().top
7  }, 500) /* 500 milliseconds*/
8  /*
9    Hint:
10    $("#" + $(this).attr("id")) => #login-section
11    so that html will scroll to #login-section which is our specific div
12  */
13})