JSFiddle - React, Tailwind, and code Playground

HTML

<a href="http://yahoo.com" id="mylink">Yahoo!</a>

JavaScript

document.getElementById("mylink").onclick = function(evnt) {
    if (
        evnt.ctrlKey || 
        evnt.shiftKey || 
        evnt.metaKey || 
        (evnt.button && evnt.button == 1)
    ){
        return;
    }
    evnt.preventDefault();
    
    alert("clicked");
    return false;
}