Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery scroll to specific div

/* HTML LAYOUT */
<div class="my-div" id="login-section"></div>
/* JQUERY Code*/
$(".my-menu-link").click(function () {
  $("html, body").animate({
    scrollTop: $("#" + $(this).attr("id")).offset().top
  }, 500) /* 500 milliseconds*/
  /*
    Hint:
    $("#" + $(this).attr("id")) => #login-section
    so that html will scroll to #login-section which is our specific div
  */
})
Comment

scroll to div jquery

$('html,body').animate({scrollTop: $("#div-you-are-scrolling-too").offset().top},'slow');
Comment

PREVIOUS NEXT
Code Example
Javascript :: synchronous ajax 
Javascript :: how to remove the parent div from the child in jquery 
Javascript :: js remove trailing slash 
Javascript :: get value onChange from mat-select angular 
Javascript :: jquery get form data 
Javascript :: eslint change max line length 
Javascript :: console.log ejs 
Javascript :: npm remove dev dependencies from node_modules 
Javascript :: Get First Day and last day of week javascript 
Javascript :: how express serve public folder 
Javascript :: onclick jquery show alert 
Javascript :: react js usehistory push and pass props 
Javascript :: js math round up 
Javascript :: cypress clear session storage 
Javascript :: npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve 
Javascript :: how to raise exception in js 
Javascript :: javascript add event listener to all input 
Javascript :: javascript reduce function to get sum of object value 
Javascript :: check if a variable is array in javascript 
Javascript :: window.onload 
Javascript :: javascript get length of object 
Javascript :: array sum javascript 
Javascript :: select input by name javascript 
Javascript :: socketio cdn 
Javascript :: listen prop change vuejs 
Javascript :: javascript get device gpu info 
Javascript :: check undefined object javascript one liner set to emtpy 
Javascript :: react native text area form 
Javascript :: javascript loop through array backward 
Javascript :: javascript dom id selector 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =