how to detect a button click in javascript

JavaScript
if(document.getElementById('button').clicked == true)
{
   alert("button was clicked");
}<input id="button" type="submit" name="button" value="enter"/>
Source

Also in JavaScript: