107
Use the onclick HTML attribute.
The
onclickevent handler captures a click event from the users’ mouse button on the element to which theonclickattribute is applied. This action usually results in a call to a script method such as a JavaScript function [...]
I would generally recommend using element.attachEvent (IE) or element.addEventListener (other browsers) over setting the onclick event directly as the latter will replace any existing event handlers for that element.
attachEvent / addEventListening allow multiple event handlers to be created.