JSFiddle - React, Tailwind, and code Playground
HTML
<a href="javascript:void(0)">CLICK</a>
JavaScript
$(document).ready(function () {
$('a').on('click', function () {
// $('<script/>').text('test()').appendTo('head');
$("head").append($("<script />", {
html: 'test()'
}))
$("head").append($("<script />", {
text: 'test()'
}))
});
});
function test(){
console.log("running")
}