大象传媒

JavaScript mouse events

Using JavaScript, functions are created that will change what appears on screen depending upon what the user does with the mouse.

There are a number of mouse events that are used in HTML code to trigger the execution of JavaScript functions.

  • onmouseout - occurs when the cursor is moved away from an element such as a button or a heading.
  • onmouseover - occurs when the cursor is hovered over an element such as a button or a heading.
  • onmousedown - occurs when the user presses a mouse button over an element.
  • onmouseup - occurs when the user releases the mouse button over an element.
  • onclick - occurs when the user clicks on an element such as a button or hyperlink.
  • onmousemove - occurs when the cursor is moving over an element such as an image or menu.