I'm using <a href>
element along with :target
css selector to show a <div>
which by default is set to display:none
. Problem is, that when I click on the link to show that <div>
, it is automatically scrolling down my site towards that <div>
.
Is there a way to stop the screen movement?
Unfortunately I am not yet proficient in anything besides CSS and HTML.
You can use event.preventDefault() to avoid this. Something like this:
$('a.yourclass').click(function(e)
{
//your code
e.preventDefault();
});
OR:
<a href="javascript:void(0)" onclick="somefunction(); return false;">link</a>
in the link enter:
<a href="javascript:void();">Link here</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With