I have the following jQuery code
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
This is a scrolling plugin which scrolls down smoothly to internal links in a page. I would like to offset the school by -140px so it does not scroll right to the DIV.
How can this be achieved?
Try...
$('html, body').stop().animate({
'scrollTop': $target.offset().top-140
}, 900, 'swing', function () {
window.location.hash = target;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With