JSFiddle - React, Tailwind, and code Playground
HTML
<textarea>
<a href='www.google.com'></a>
</textarea>
<button id="btn">change</button>
JavaScript
var new_url = "www.stackoverflow.com";
$("#btn").click(function(){
var text = $('textarea').html();
$('textarea').html(text.replace(/(<a [^&]*href=['"])[^'"]*(['"][^&]*>)/, "\$1"+new_url+"\$2"));
});