ReadingHTML: Clicking anchor with href # moves the page Permalink

Situation:

I need to add a tabbed content with jQuery. Each anchor that points to tabs inside the content has a href of “#”.

It doesn’t need any href, but it needs to act as an anchor; thus the “#”

Solution One:

Add after “#” the div name of the tabbed content.

<div id="tabbed">
<a href="#tabbed" title="Tab One">Tab One</a>
<a href="#tabbed" title="Tab Two">Tab Two</a>
</div>

But adding the name of div (container of tabbed content) will move the page, either up or down – depending on my position of viewing, so that the container div is placed at the top of window.

Solution Two (The perfect solution, also)

Add onclick=”return false;” to the anchor to move the page up, regardless of your position / etc.

<div id="tabbed">
<a href="#" title="Tab One" onclick="return false;">Tab One</a>
<a href="#" title="Tab Two" onclick="return false;">Tab Two</a>
</div>

No responses Comments RSS

Do you want to comment?


Looking for more? See all posts on the blog.