html scroll to element code example
Example 1: javascript scroll to element
document.getElementById("divId").scrollIntoView();
Example 2: javascript scroll to bottom of div
//scroll to the bottom of "#myDiv"
var myDiv = document.getElementById("myDiv");
myDiv.scrollTop = myDiv.scrollHeight;
Example 3: scroll to a section of your page html
html {
scroll-behavior: smooth;
}
Example 4: how to scroll through an object js
// Requiring the lodash library
// console: npm i --save lodash
const _ = require("lodash")
// Use of _.forEach() method
_.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
console.log(key)
})