javascript smooth scroll to anchor element

Solutions on MaxInterview for javascript smooth scroll to anchor element by the best coders in the world

showing results for - "javascript smooth scroll to anchor element"
Juliana
03 Sep 2016
1//add smooth scrolling when clicking any anchor link
2document.querySelectorAll('a[href^="#"]').forEach(anchor => {
3    anchor.addEventListener('click', function (e) {
4        e.preventDefault();
5        document.querySelector(this.getAttribute('href')).scrollIntoView({
6            behavior: 'smooth'
7        });
8    });
9});
10//<a href="#someOtherElementID"> Go to Other Element Smoothly </a>
queries leading to this page
smooth scroll anchor linksjs click anchor to section smooth scrollmake page scroll smoothly on hrefhtml smooth scroll to anchorsmooth scroll anchors jshtml section anchor smooth scrolljquery smooth scroll anchorscroll smoothly on clicking anchor tagscroll to section on link clickvanilla javascript smooth scroll to anchorsmooth scroll anchor javascriptjs scroll to anchorsmooth scroll anchorsmooth scroll jsjavascript anchor scroll smooth pure javascriptsoftscroll jsanchor link scrollsmooth scrollanchor smooth scrollsmooth scroll javascript active anchor linkssmooth scroll 22 23 22smooth scroll when click on linksmooth scroll a link js htmlanimate all anchorsmooth anchor scrolling jsjs smooth scroll to anchorsmooth scroll on click to idpure javascript smooth scroll anchorjavascript smooth scroll anchor doesnt workanchor scroll smoothjs go to anchor smoothsmooth hrefsmooth scrollsmooth scroll to anchorjavascript anchor link smooth scrollhow to get a smooth scroll on click anchor tagjquery scroll to anchor smoothsmoothscrooljavascript smooth scroll to anchorsoft scroll same pagelink smooth scroll anchor jssmoothscroll jshash smooth scrolljavascript hashtag smooth scrolljavascript scroll to anchor smoothjavascript smooth scroll anchorsmoth scrollsmooth scroll to anchor javascriptsmooth scroll to specific div on click javascriptjavascript smooth anchor scroll smooth scrool anchor jsjquery smooth scroll to anchorsmooth scroll jssmooth anchor scrollsmooth anchor scroll jshow to create smooth scrolling anchor linkssmooth scroll javascript anchorjavascript smooth scroll to anchor element