Reputation: 992
When I disable javascript on my site, I want to prevent the default behavior of the anchor tag.
<li class="last"><a href="#" id="viewexample" class="btn btn-view">View<span> </span></a></li>
How can I prevent this link from jumping to the top of the page when javascript is disabled?
Upvotes: 0
Views: 938
Reputation: 30206
html & js:
<a onclick="document.location.href='#'">View<span> </span></a>
css:
a:hover {cursor:pointer;}
Upvotes: 1
Reputation: 32107
You could try:
<a href="javascript:void(0)">Link</a>
or
<a href="#noop">Link</a> <!-- #noop does not exist -->
Upvotes: 0
Reputation: 69934
Don't use the <a>
tag at all, given it is not a real link?
You could change it into a button or add events directly to the <li>
s.
Upvotes: 2
Reputation:
Without the help of Javascript, since the href is pointing to #, you can't prevent it from jumping. You would have to change the # to an actual link.
Upvotes: 0