So this is the current code I have
$(document).ready(function() {
$('.abouta').click(function(){
$('html, body').animate({scrollTop:308}, 'slow');
return false;
});
$('.portfolioa').click(function(){
$('html, body').animate({scrollTop:708}, 'slow');
return false;
});
$('.contacta').click(function(){
$('html, body').animate({scrollTop:1108}, 'slow');
return false;
});
});
When you click a link e.g. 'abouta' it scrolls to that specific section of the page. I'd rather do a scrollTo and then the id of a div so that I don't have to keep changing the scrollTo position if I change padding etc. Is there any way? Thanks
instead of
use
this will return the absolute top position of whatever element you select as
#div_id
My solution was the following:
if you want to scroll just only some div, can use the div id instead of 'html, body'
use
try this
try this: