I want to know which form of the following structures is the one that's semantically correct, if I want to use an achor that triggers a javascript callback but doesn't make the window navigate to another place:
The javascript:
window.addEventListener('load', function() {
document.getElementById('AuxAnchor').addEventListener('click', function(e) {
// Do something
e.preventDefault(); // Don't navigate to anywhere
}, false)
}, false);
The HTML:
Defined href attribute with blank value:
<a id="AuxAnchor" href="">Click me</a>
Defined href attribute with missing in-document ID:
<a id="AuxAnchor" href="#">Click me</a>
Undefined href attribute:
<a id="AuxAnchor">Click me</a>
Note that in the latter (undefined href attribute) I have to simulate an hyperlink appearance by using styles, but that's basically just a cosmetic issue, and it doesn't bother me at all to do so.