JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<style>
#foo {
border: solid blue 1px;
width: 30%;
padding: 10px;
}
</style>
</head>
<body>
<p id="foo">My Event Element</p>
<p>Click on the above element..</p>
</body>
</html>
<script>
function bar() {
var p = document.getElementById("foo");
p.onclick = showAlert;
var x = 5;
alert("bar function was called !");