Values of an a[href] to not require preventDefault
by steveukx
HTML
<a>Click Me!</a>
<a href="javascript:;">Click Me: JS</a>
<a href="#">Click Me: hash</a>
<output></output>
CSS
html {
font: 10pt/1.5 Arial, Sans-Serif;
}
a {
display: block;
color: #000;
text-decoration: none;
}
a:hover {
color: #333;
}
output {
display: block;
border-top: 1px solid #eee;
padding-top: 0.5rem;
margin-top: 0.5rem;
}
JavaScript
[].forEach.call(document.querySelectorAll('a'),
function (a) {
a.addEventListener('click', function (e) {
console.log("Clicked");
}, true);
});
window.setInterval(function () {
document.querySelector('output').innerHTML = "History items: " + history.length;
}, 25);