Home >Web Front-end >HTML Tutorial >Detailed introduction to the basic knowledge of html event attributes

Detailed introduction to the basic knowledge of html event attributes

巴扎黑
巴扎黑Original
2017-06-16 17:34:541433browse

Introduction to event attributes:

One of the new features of HTML 4 is that HTML events can trigger actions in the browser. For example, when a user clicks on an HTML element, a section of JavaScript## is started. #.

There are a large number of

event handlers built into modern browsers. These processors monitor specific conditions or user actions, such as a mouse click or the completion of loading an image in the browser window. By using client-side JavaScript, you can add certain event handlers as attributes to specific tags and execute one or more JavaScript commands or functions when the event occurs.

The value of an event handler is one or a series of Javascript expressions, methods, and function calls separated by semicolons and enclosed in quotes. When the event occurs, the browser executes these codes. For example, when you move your mouse over a hyperlink, a JavaScript function is launched. Browsers that support JavaScript support a special "mouse over" event handler in the tag - called

onmouseover to do the job:


To learn more about event programming, please visit JavaScript tutorials and DHTML tutorials provided by W3School.

The following table provides standard event attributes that can be inserted into HTML/XHTML elements to define event behavior.

Window Events

Only valid in body and frameset elements.

Attribute Value Description

onload Script Execute the script when the document is loaded

onunload Script Execute the script when the document is unloaded

Form element event (Form Element Events)

is only valid in form elements.

Attributes Values ​​Description

onchange script Execute script when the element changes

onsubmit script Execute script when the form is submitted

onreset script When the form is reset Set time execution script

onselect Script Execute script when element is selected

onblur Script Execute script when element loses focus

onfocus Script Execute script when element gains focus

Image Events

This attribute can be used for img elements:

Attribute Value Description

##onabort Script Execute script when image loading is interrupted

Keyboard Events

Invalid in the following elements: base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style and title elements.

Attribute                                                                                                  

onkeydown Script                                                                   # #onkeyup Script Execute the script when the keyboard is released

Mouse Events

Invalid in the following elements: base, bdo, br, frame, frameset, head, html, iframe , meta, param, script, style and title elements.

Attributes Values ​​Description

onclick Script Execute the script when the mouse is clicked

ondblclick Script Execute the script when the mouse is double-clicked

onmousedown

Script Execute the script when the mouse button is pressed

onmousemove

Script Execute the script when the mouse pointer moves

onmouseout

Script When the mouse Execute the script when the pointer moves out of an element onmouseover Script Execute the script when the mouse pointer hovers over an element

onmouseup Script Execute the script when the mouse button is released

The above is the detailed content of Detailed introduction to the basic knowledge of html event attributes. For more information, please follow other related articles on the PHP Chinese website!

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