javascript smooth scroll to anchor element
//add smooth scrolling when clicking any anchor link
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
//<a href="#someOtherElementID"> Go to Other Element Smoothly </a>
Also in JavaScript:
- ojs link contact page
- javascript sendredirect
- delete local storage javascript
- how to add prototype in javascript
- nodejs get file size
- reset navigation to specific tab react-navigation
- react router history push parameter
- angular cli skip-tests
- check to see if number is a decimal javascript
- serializeobject jquery
- core.js:12799 Can't bind to 'ngForIn' since it isn't a known property of 'ng-container'.
- react place div at center of page
- sort array of objects by string property value
- javascript get elements that exist in two arrays
- express download file
- ways to show image in react native
- vuejs :class
- renemane object key js
- npm react router 6.0.0-alpha.2
- addclass to elementref angular
- convert json into map in java example
- sigma js load json
- javascript get seconds between two dates
- object inside object javascript