JSFiddle - React, Tailwind, and code Playground

HTML

<a href="test.html">anchor</a>

JavaScript

var anchors = document.getElementsByTagName('a');
for(i = 0; i <= anchors.length; i++) {
    anchors[i].onmousedown = function() {
        var link = this.getAttribute('href');
        alert(link);
    }
}