I've implemented the script below to execute the action mentioned in the title.
<script type="text/javascript">
var jump=function(e)
{
if (e){
e.preventDefault();
var target = $(this).attr("href");
}else{
var target = location.hash;
}
$('html,body').animate(
{
scrollTop: $(target).offset().top
},1000,function()
{
location.hash = target;
});
}
$('html, body').hide();
$(document).ready(function()
{
$('a[href^=#]').bind("click", jump);
if (location.hash){
setTimeout(function(){
$('html, body').scrollTop(0).show();
jump();
}, 0);
}else{
$('html, body').show();
}
});
</script>
The functionality works perfectly, but I encounter an issue with my fixed header overlapping the div after scrolling. To address this, I aim to adjust the scroll target by subtracting 80px. How can I update the code to achieve this modification?
You can view a live version of this on
robertkoh.net/Electrotemp/index.html
If you click on 'ducted vacuum systems', it will direct you to the products and services page and scroll to the relevant section. However, you'll notice that the fixed header partially covers the content.