JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head></head>
<body>
<table>
<tr>
<td><a href="javascript:void(0)" id="aTag">TEST</a>
</td>
</tr>
</table>
<script>
function showAlert(text) {
alert(text);
}
x = document.getElementById('aTag');
x.setAttribute('onclick', "alert('Hello World')"); //WORKS
x.setAttribute('onclick', "showAlert('Hello World')"); //DNW (showAlert is not defined)
</script>
</body>
</html>