javascript onclick event fired page jumps to top of page

Posted on March 12, 2010. Filed under: jQuery | Tags: , |

I had arrised one issue with javascript event calling code where I had a html link doing specific tasks
for onclick event. Since the appear on bottom of my page,

when I click on the link the browser focus jumps to top of the page every time , I clicked.

I had write , where this proble produced,

<a href="#" onclick="dofunct()">click me</a>

This is really very frustrating as everytime I click on that link, the browser jumps to top of page. After a long search, I got solution for problem by simple replacing # with JavaScript void function.

<a href=”javascript:void(0);” onclick=”dofunc()”>click me</a>

It neatly solved my jump problem!

<pre lang=”ruby”>
Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...