What is an event
JavaScript to create dynamic pages. Events are behaviors that can be detected by JavaScript. Each element in a Web page can produce events that can trigger JavaScript functions or programs.
1. Mouse click event (onclick)
OnClick is a mouse click event that occurs when the mouse is clicked on a Web page. The program block of the onclick event call is executed, and is usually used with the button.
Example: When we click the button, we trigger the OnClick event and call two numbers and the function add2 ().
Note: In a Web page, if you use events, you set the event properties in that element.
2, the mouse after the event (onmouseover)
the mouse passes the event, and when the mouse moves over an object, the object triggers the onmouseover event and executes the program called by the onmouseover event.
When the mouse passes the OK button, the message () function is invoked, which pops up the Messages dialog box.
3. Mouse move off event (onmouseout)
The mouse moves the event, and executes the onmouseout called program when the mouse moves the current object.
When the mouse moves the "Click me" button, call the message () function, pop-up Messages dialog box.
4. Cursor Focus event (onfocus)
When an object in a Web page obtains a node, the program that executes the onfocus call is executed.
When the Drop-down list gets focus, the message () function is invoked, and the dialog box "" Please choose your current career! ”。
5, the loss of focal events (onblur)
the onblur event and the onfocus are relative events that trigger the onblur event and execute the invoked program when the cursor leaves the current focused object.
<! DOCTYPE html>
<! DOCTYPE html>
7. Text Box content Change event (onchange)
triggers the onchange event by changing the contents of the text box, while executing the invoked program.
8. Loading events (onload)
The event occurs immediately after the page load completes, executing the invoked program at the same time.
Note: 1. When the page is loaded, the OnLoad event is triggered and the event is written in the <body> tag.
2. The load page for this section can be understood as opening a new page.
The following code, when loading a new page, pop-up dialog box "load, please wait ...".
9. Uninstall event (onunload)
When the user exits the page (page close, page refresh, etc.), the OnUnload event is triggered and the invoked program is executed.
Note: Different browsers have different support for onunload events.
The test results found that the other browsers did not perform the application only in IE browser.
The above is about nine kinds of state of JavaScript event response, hope to be helpful to everybody's study.