JSFiddle - React, Tailwind, and code Playground
by Ehsan Sajjad
HTML
<a href="#oldLink" id="link">link</a>
JavaScript
$(function () {
$("#link").on("click", function (e) {
if ($(this).attr('href') === '#oldLink') // check if it is old link
{
e.preventDefault(); //stop default behaviour
$(this).attr("href", "#newLink"); // change link href
$(this).trigger("click"); // click link programmatically
}
});
});