JavaScript answer
If you would like to scroll to an element smoothly with “pure JavaScript” you could do something like this:
document.querySelector('#menudiv').scrollIntoView({ behavior: 'smooth' });
More information is here: Element.scrollIntoView()
NOTE: Please see Can I use… Support tables for HTML5, CSS3, etc. for the latest browser support…
jQuery answer
If you would like to scroll to an element smoothly using jQuery then you could do something like:
$(document).ready(function() { $(".btns").click(function() { $("html").animate( { scrollTop: $("#menudiv").offset().top }, 800 //speed ); }); });
Related Posts:
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- jQuery document.createElement equivalent?
- Bootstrap Dropdown menu is not working
- Change Background color (css property) using Jquery
- Set timeout for ajax (jQuery)
- Use images like checkboxes
- How can I select an element by name with jQuery?
- Why is the jquery script not working?
- Refresh/reload the content in Div using jquery/ajax
- How to get height of div in px dimension
- Retrieve the position (X,Y) of an HTML element
- How to display raw JSON data on a HTML page
- Why is jquery show() not working in example
- jQuery scrollTop() method not working
- Fully responsive HTML5 video
- Cannot read property ‘style’ of undefined — Uncaught Type Error
- How to use aria-expanded=”true” to change a css property
- How to set “style=display:none;” using jQuery’s attr method?
- Failed to load resource: the server responded with a status of 404 (Not Found)
- How to change CSS using jQuery?
- How to properly use jsPDF library
- ReferenceError: $ is not defined
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- jQuery.click() vs onClick
- jQuery Get Selected Option From Dropdown
- Include another HTML file in a HTML file
- How to add jQuery code into HTML Page
- What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element [duplicate]
- jquery SlideToggle effect in upward direction?
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Get class name using jQuery
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- querySelector vs. getElementById
- How to generate a simple popup using jQuery
- CSS height 100% percent not working
- JavaScript get element by name
- JavaScript Loading Screen while page loads
- Completely disable scrolling of webpage
- Jquery swipe left or right on mobile
- How to move an element into another element?
- Bootstrap Dropdown menu is not working
- Bootstrap Dropdown menu is not working
- Create table with jQuery – append
- How to convert selected HTML to Json?
- How to Open New window on every Click
- How to print HTML content on click of a button, but not the page?
- Play an audio file using jQuery when a button is clicked
- How to move an element after another element using JS or jquery?
- Bootstrap 4 Dropdown Menu not working?
- document.getElementsByClassName().innerHTML always returns “undefined”
- Jquery button click() function is not working
- Change text on hover, then return to the previous text
- Textarea Auto height
- How do I check whether a checkbox is checked in jQuery?
- Print the contents of a DIV
- How to write inside a DIV box with javascript
- jQuery count child elements
- Embedding instagram webpage inside an iframe
- How do I check if an element is hidden in jQuery?
- jQuery: Uncaught Error: Syntax error, unrecognized expression
- Creating a div element in jQuery
- How to use in jQuery :not and hasClass() to get a specific element without a class
- Force div to be topmost element of any and all webpages
- Clearing my form inputs after submission
- Get class list for element with jQuery
- Reload an iframe with jQuery
- Highlight a word with jQuery
- “Uncaught TypeError: a.indexOf is not a function” error when opening new foundation project
- how to display a div triggered by onclick event
- How can I use jQuery to run MySQL queries?
- FormData append not working
- getContext is not a function
- How to change the text of a label?
- Print a div content using Jquery
- JavaScript – Count Number of Visitor for Website
- Using “×” word in html changes to ×
- Getting or changing CSS class property with Javascript using DOM style
- Fire oninput event with jQuery
- Changing the selected option of an HTML Select element
- HTML anchor link – href and onclick both?
- How to create checkbox inside dropdown?
- How can I know which radio button is selected via jQuery?
- Positioning element at center of screen
- How to scroll to top of page with JavaScript/jQuery?
- How to make HTML element resizable using pure Javascript?
- WordPress Bootstrap Handburger Menu Wont Open
- Adding JavaScript to a WordPress website
- Adding a Calculator to a WordPress Page
- Putting custom html/js page into Elementor as it’s own block
- Add other class content with reference class value
- internal anchor links no longer working after upgrade
- Overriding inline !important CSS with Javscript code snippet with media query
- Can’t Listen to KeyDown in TInyMCE Iframe (jQuery) and Pass it to Parent HTML FORM
- Unable to use Datepicker in a table when inserting a row
- Getting click on item to open closest relevant element (popup) with jQuery
- jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser
- Hide CSS class only in single post pages
- Possible jquery / library conflict in plugin usage
- Element works, but not on wordpress site [duplicate]
- Styling parent based on a child element of a child in a WordPress page