Home  >  Article  >  Web Front-end  >  A brief discussion on the attribute list of JavaScript events_Basic knowledge

A brief discussion on the attribute list of JavaScript events_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:12:081118browse

One of the new features of HTML 4.0 is the ability to enable HTML events to trigger actions in the browser, such as starting a piece of JavaScript when the user clicks on an HTML element. Below is a list of properties that can be inserted into HTML tags to define the behavior of the event.

The content of the The
Attributes When did this incident occur...
onabort The loading of the image was interrupted.
onblur The element loses focus.
onchange field was changed.
onclick Event handler called when the user clicks on an object.
ondblclick Event handler called when the user double-clicks an object.
onerror An error occurred while loading the document or image.
onfocus element gets focus.
onkeydown A keyboard key was pressed.
onkeypress A keyboard key is pressed and released.
onkeyup A keyboard key was released.
onload A page or image is loaded.
onmousedown The mouse button is pressed.
onmousemove The mouse is moved.
onmouseout The mouse moves away from an element.
onmouseover Move the mouse over an element.
onmouseup The mouse button is released.
onreset The reset button is clicked.
onresize The window or frame was resized.
onselect Text is selected.
onsubmit The confirmation button is clicked.
onunload User exits the page.

Mouse/Keyboard Properties

Attributes Description
altKey Returns whether "ALT" was pressed when the event was triggered.
button Returns which mouse button was clicked when the event was triggered.
clientX Returns the horizontal coordinate of the mouse pointer when the event is triggered.
clientY Returns the vertical coordinate of the mouse pointer when the event is triggered.
ctrlKey Returns whether the "CTRL" key was pressed when the event was triggered.
metaKey Returns whether the "meta" key was pressed when the event was triggered.
relatedTarget Returns the node related to the event's target node.
screenX Returns the horizontal coordinate of the mouse pointer when an event is triggered.
screenY Returns the vertical coordinate of the mouse pointer when an event is triggered.
shiftKey Returns whether the "SHIFT" key was pressed when the event was triggered.

Events of common HTML elements:

onclick (click),
ondblclick (double click),
onkeydown (key down),
onkeypress (click the button),
onkeyup (key release),
onmousedown (mouse down),
onmousemove (mouse movement),
onmouseout (the mouse leaves the element range),
onmouseover (mouse moves to the element range),
onmouseup (mouse button release),
oncontextmenu (triggered when the right-click of the mouse displays the "right-click menu" in the browser)

The above is the entire content of this article, I hope you all like it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn