Event Handlers

An event is something which user does, or browser does such as mouse click or page loading are examples of events, and JavaScript comes in the role if we want something to happen on these events.

HTML provides event handler attributes which work with JavaScript code and can perform some action on an event.

HTML can have following events such as:

  • Form events: reset, submit, etc.
  • Select events: text field, text area, etc.
  • Focus event: focus, blur, etc.
  • Mouse events: select, mouse up, mouse move, mouse down, click, double click, etc.

List for Windows Event Attributes:

Event NameHandler NameOccurs When
onBlurblurWhen form input loses focus
onClickclickWhen the user clicks on a form element or a link
onSubmitsubmitWhen a user submits a form to the server.
onLoadloadWhen page loads in a browser.
onFocusfocusWhen a user focuses on an input field.
onSelectselectWhen a user selects the form input filed.


<input type="button" value="Click" onclick="alert('Hi, how are you')">