JSFiddle - React, Tailwind, and code Playground

HTML

<a href="ahref">a</a> 
<a href="bhref">b</a>

JavaScript

$(document).ready(function () {
    $('a').each(function () {
        var get_href = $(this).attr("href");
        var new_ele = $("<button type='button'>test</button>");
        (function (get_href) {
            new_ele.click(function () {
                alert(get_href);
            });
        })(get_href);
        $(this).append(new_ele);
    });
});