Eventos OnClick
document.getElementById("myBtn").onclick=function(){displayDate()};
function displayDate()
{
document.getElementById("demo").innerHTML=Date();
}
//------------
<button onclick="myFunction()">Click me</button>
<p id="demo" onclick="myFunction()">Click me to change my text color.</p>
//------------
<input value="Click" onclick="alert('Click')" type="button">
//------------
document.getElementById(id).setAttribute('onclick','myFunction()')
Xanthous Xenomorph