I have an anchor link with mailto:example@email.com
as href, but it jumps to the top of the page when it is clicked. I want to prevent that from happening.
I tried e.preventDefault()
in my js, which works but has the problem that it won't open the email client anymore.
scenario:
I have a "Get in Touch" link at the bottom of my page. It should open the email client (which is working). The problem is that it jumps to top of page everytime it is clicked. Is there a way to prevent that from happening?
here is what the anchor link look like:
<a class="get-in-touch" href="mailto:email@gmail.com">Get In Touch</a>
here is what I tried already.
$(".get-in-touch").on("click",function(e){
e.preventDefault();
window.location.href = $(this).attr("href");
});
but that didn't work. Still jumps to top of page.