JSFiddle - React, Tailwind, and code Playground
by Michael Prosser
HTML
<ul>
<li><a href="#item1">Item 1</a></li>
<li><a href="#item2">Item 2</a></li>
<li><a href="#item3">Item 3</a></li>
</ul>
JavaScript
var links = document.querySelectorAll('a');
for (var i = 0; i < links.length; i++) {
links[i].addEventListener('click',function(){
document.location.hash = '';
});
}
window.addEventListener("hashchange", function(){
if(document.location.hash != ''){
console.log("changed to " + location.hash);
}
});