smooth scrolll to id js
$("#button").click(function() {
$('html, body').animate({
scrollTop: $("#myDiv").offset().top
}, 2000);
});html {
scroll-behavior: smooth;
}
/* No support in IE, or Safari
You can use this JS polyfill for those */
http://iamdustan.com/smoothscroll/
// handle links with @href started with '#' only
$(document).on('click', 'a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
return;
}
// prevent standard hash navigation (avoid blinking in IE)
e.preventDefault();
// top position relative to the document
var pos = $id.offset().top;
// animated top scrolling
$('body, html').animate({scrollTop: pos});
});
Also in JavaScript:
- what is amqp10 policy nodejs
- node check if file exists
- ngingx proxy express get real ip
- arrow function in javascript
- Unexpected end of JSON input while parsing near '...fcd15e632426a1be","ta'
- json datetime
- what is javascript token
- jquery bind function to multiple events
- function(global factory)
- js remove the last character of a string
- find length of longest string in array javascript
- ckeditor get content html
- javascript switch assignment
- jquery count selected options
- JAVASCRIPT EVENT.TARGET
- require is not defined javascript
- how to pass dynamic string in string javascript
- export multiple functions react
- how to refrence image in dart angular
- python turnary
- javascript conditional
- Javascript >> Google Script array concat doesn't work
- scroll to top
- check multiple ifield if it's blank in jquery