JSFiddle - React, Tailwind, and code Playground
HTML
<a id="p1">I am link 1</a>
<a onclick="javascript:alert('hi');">I am link 2</a>
<a>I am link 3</a>
<a>I am link 4</a>
JavaScript
$(document).ready(function()
{
document.getElementById('p1').onclick = function() { alert('hi'); };
$('a').each(function()
{
if(this.onclick == null)
{
alert("Link " + this.innerText + " does not have a onclick event");
}
else
{
alert("Link " + this.innerText + " does have a onclick event");
}
});
});