July 12th in Javascript by .

Fix-> JQuery onclick browser jumps to top of page!

 

JQuery onclick jumps to top of page

i had an issue with jquery code where i have 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 jumps to top of the page every time i click.

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

This is really very frustrating as everytime i click a link, the browser jumps to top of page. After a long search, i fixed the problem by replacing # with javascript void function.

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

It neatly solved my jump problem!

Similar Posts:

21 Comments

  • Peet
    August 10, 2009
  • Dave H
    January 26, 2010
  • Charlotte Coleman
    February 18, 2010
  • Ricardo Zea
    March 2, 2010
  • Dan McKenzie
    September 10, 2010
  • Hungary
    November 9, 2010
  • Mohio
    January 20, 2011
  • crossan
    February 22, 2011
  • Kris
    April 12, 2011
  • Rathinam
    April 20, 2011
  • Ali Reza salimzadeh
    June 27, 2011
  • Mark
    July 4, 2011
  • Mark
    July 4, 2011
  • Mark
    July 4, 2011
  • Bouncer
    July 5, 2011
  • mmorpg
    July 23, 2011
  • Kumar
    January 12, 2012
  • oraclemind
    April 13, 2012
  • Idan Rubin
    May 27, 2012
  • dani
    September 20, 2012
  • Mayank
    February 7, 2013

Leave A Comment.






5 + = thirteen

Please wrap all source codes with [code][/code] tags. Powered by