I have a link
<a href="#">has a jQuery click handler</a>
My jQuery works the way it’s supposed to…however the hash # tag is making my browser jump to the top of the page on every click.
Is there any way to get around this? I tried removing the # but it changes my css styling.
You should add a
return false;to the end of your click handler if you want to resolve the issue quick and dirty.However, return false forces you to exit and virtually stops event propagation. Since you are using the jquery javascript library, you also have the option of using the
preventDefault()method instead, which removes the default action and allows the function to keep runnning.