If you want an event or a link to an empty javascript call, there are several ways, of which I can think of:
<a href="#">Method 1</a> <- Ugh... changes URL in browser
<a href="javascript:;">Method 1</a> <- My currently preferred method
<a href="javascript:void(0);">Method 1</a> <- Another approach?
What is the best way in terms of cross-browser compatibility and shortness?
Don't use links if they don't... well, link to anything.
Instead, use a span
somewhat like this:
<span class="spanlink" onclick=something>This is some text</span>
And in your CSS:
.spanlink {
text-decoration: underline;
color: blue;
cursor: pointer; /* Ragnagord's suggestion in comments */
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With