HTML event onclick

From Htmlpedia
Jump to: navigation, search

Event Attribute onClick

onClick is an event attribute, it takes Javascript-code as a value. The code will be executed when:

  • The user presses the mousebutton while hovering above the element, and then releases it while hovering above the element.
  • The element is focused and the Return key is pressed


In this example, the user will receive a messagebox saying "You clicked on the text", after clicking anywhere on the text "Click me"

<a onClick="alert('You clicked on the text')">Click me</a>


onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup