In my page there are some anchor that has no link, like this:
<a href="#">Anchor</a>
When I click anchor that is bottom of the page, Page is scrolling to top. I want to keep page position, if I clicked the link. How Can I do this. (no js is better for me)
I hope, I could explain.
Thanks in advance.
<a href="#noname">Anchor</a>
Make sure that noname
you didn't use for id
attribute of any tag or name
attribute of a
tag.
You'll still have to use JS, but you can do it inline:
<a href="javascript:void(0);">Test</a>
Demo: http://jsfiddle.net/7ppZT/
Alternatively, you can capture the event:
$('a[href^="#"]').click(function(e) {
e.preventDefault();
});
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