j$( document).ready(function(){
$('a[href^="#"]').click(function(){
var speed = 800;
var href=$(this).attr("href");
var target=$(href=="#"||href==""?'html':href);
var position = target.offset().top;
$("html, body").animate({scrollTop:position}, speed, "swing");
return false;
});
});
Here is the code used for scrolling top, and I would like to value var position.
For example, how can I change the code if I want to bring the scroll position -50px above or below the current code position?
I'm sorry if it's difficult to understand and basic questions.Thank you for your cooperation.
jquery
I think I just need to add +50 to the position.
var position=target.offset().top+50;
© 2024 OneMinuteCode. All rights reserved.