Search code examples
javascripthtmlhyperlinkclick

Preventing javascript:void(0) links from showing link address on hover


I have a javascript web application that contains lots of clickable elements that are currently all <a href='javascript:void(0)'> elements. Because there are so many links, as the user hovers over the page, javascript:void(0) flickers on and off in the lower left hand corner of browsers such as chrome and firefox which is annoying and ugly.

I know that I should leave these elements as links for accessibility and mobile friendliness. Is there a way to prevent this behavior in the browser? Alternatively I could convert all of the <a href='javascript:void(0)'> tags to <div> tags on the fly for non-touch browsers but that seems messy.


Solution

  • Those elements aren't hyperlinks in the first place, so replace them with <span> elements styled with cursor:pointer (and no href attribute).