I am trying to make an anchor link where when you click on it scroll down to another element. I have tried doing so with the answers from a previous question: Smooth scrolling when clicking an anchor link Using this code from it
$('a[href*=#]').click(function(event){
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
event.preventDefault();
});
When I use this code with this HTML
<a id="des" href="#scroll">
<img name="scroll" id="scroll" src="whatever">
It does not smooth scroll, but instead instantly jump here. It does also not jump to the right place. It jumps under the image so that you cannot see the image.
What I am trying to do: I am trying to have it so when I click on this anchor element, it smooth scrolls to this image without cutting it out. What I mean by this is when I do it now It skips over the image.