YouTube video: https://www.youtube.com/watch?v=r-8isv_TnVA
Stackblitz: https://stackblitz.com/edit/js-mbehz9?file=index.js
YouTube video: https://www.youtube.com/watch?v=r-8isv_TnVA
Stackblitz: https://stackblitz.com/edit/js-mbehz9?file=index.js
/* ---------------------------------------------------------------------------------------------------------- | |
03 scroll to #section-id-of-div | |
---------------------------------------------------------------------------------------------------------- */ | |
function smoothScroll(el, target){ | |
// if the hash is in the URL but not on the page... ex #cosmetic-surgery but not #section-this-div | |
if(el !== null){ | |
var $this = $(el), | |
target = el.hash, | |
$target = $(target); | |
// check if the target has an offset, if its NOT undefined then run the code to allow things to scroll |