JSFiddle - React, Tailwind, and code Playground

HTML

<a id="aTag" href="http://www.google.com" target="_new" onclick="return doWork();">Click to redirect</a>

JavaScript

//first assign the click handler
    $('#aTag').click(function(){
        alert("redirecting");
        //... do your work
        return true;
    });
    
    //then call programmatically
    
    $("#aTag").click();