d
Amit DhamuSoftware Engineer
 

Scroll To Position

1 minute read 00000 views
// Function/Plugin
$.fn.scrollTo = function () {
  return this.each(function () {
    $('html, body').animate(
      {
        scrollTop: $(this).offset().top,
      },
      1000
    )
  })
}

// Usage
$('#clickHandler').on('click', function () {
  $('#section2').scrollTo()
})

Credit to Jake Bresnehan at Web Design Weekly for this.