Anchor tags list creation

In your javascript function you should return false, or with jquery you can use preventDefault()

Example:

$('a').click(function(event) {
    event.preventDefault();
    // do something
});

Or in your case:

<a href=“#” onclick="foo();return false;">

Or change the href to javascript:void(0):

<a href="javascript:void(0)" onclick="foo();">

Ideally, your link degrades without javascript, so the third option will usually be avoided.


A simpler HTML fix for you: Personally speaking, for plain test links I just use href=""

For links that point to a javascript function I tend to use href="javascript:;". Either way you'll stop the page jumping.