As Many others have talked about, It can be much better continue to to implement return Fake; in the clicking handler than make use of the javascript: protocol.
I just squandered two times debugging a random sudden site redirect that should have simply just refreshed the webpage, and finally tracked it right down to a function increasing the clicking function of the . Replacing the # with javascript:void(0); preset it.
From what I've found, the void operator has three widespread makes use of in JavaScript. The a single that you're referring to, is a typical trick to create an tag a no-op. Some browsers treat tags differently dependant on whether or not they Possess a href , so this is the way to make a hyperlink with a href that does almost nothing.
bobincebobince 537k111111 gold badges672672 silver badges845845 bronze badges 15 seven Along with great publish by @bobince: I have finished some research a few months ago on cross-browser keyboard navigability of hrefs, which includes quirks and side effects; a number of you might uncover it useful: jakub-g.github.com/accessibility/onclick
Romance Film a few player who hides out in his neighbor's condominium to stay away from a girl, only to slide for the neighbor
Indeed, it can be horrible along with a small criminal offense versus humanity, but nonetheless so is Online Explorer 6 generally.
Will work just fine on most units. Having said that, on desktops this can show up as a website link which does very little whenever you click on it so it is best to think about using CSS to make it conditionally noticeable only on cellular equipment.
Some builders use href='#' for a similar objective, but this results in the browser to jump to the very best of your web page, which will not be preferred. And he couldn't just depart the href blank, for the reason that href='' is actually a backlink again to the current webpage (ie it will cause a web site refresh).
href="#" does not specify an id title, but does Possess a corresponding site - the top on the web site. Clicking an anchor with href="#" will transfer the scroll situation to the top.
zoulzoul 104k4444 gold badges263263 silver badges364364 bronze badges Add a remark
Just after creating html for number of years I spotted that I do not really know why the href attribute is named "href"
As some of the other solutions have pointed out, the a factor demands an href attribute as well as # is employed as a placeholder, but It is additionally a historical artifact.
It's a website link that backlinks to nowhere primarily (it just adds "#" onto the URL). It's useful for a range of various motives. As an example, in case you are utilizing some sort of JavaScript/jQuery and don't need the particular HTML to url everywhere.
This takes place Rather a lot now folks have bought utilized to Center-simply click-for-new-tab: it looks more info like a link, you would like to go through it in a whole new tab, but it surely seems to generally be not a true connection at all, and gives unwanted results like a blank web page or even a JS error when middle-clicked.
It is well worth mentioning that you will in some cases see void 0 when examining for undefined, simply because it demands less figures.