Events in JavaScript event-driven are triggered by mouse or hotkey actions. It mainly has the following events:
1. Click event onClick
When the user clicks the mouse button, the onClick event is generated. At the same time, the event handler or code specified by onClick will be called and executed. Usually generated in the following basic objects: button (button object), checkbox (check box) or (check list box), radio (radio button), reset buttons (important buttons) and submit buttons (submit button).
Example: The change() file can be activated through the following button:
After the onClick equal sign, you can use the function you wrote as the event handler, or you can use the internal function in JavaScript. You can also use JavaScript code directly. Example:
2. onChange change event
is emitted when the input character value changes using text or texturea elements This event will also be triggered when the status of an option in the select table item changes.
Example:
3. Select event onSelect
This event is triggered when the text in the Text or Textarea object is highlighted.
4. Get focus event onFocus
This event is generated when the user clicks the Text or textarea and select object. At this point the object becomes the foreground object.
5. Loss of focus onBlur
When the text object or textarea object and select object no longer have focus and retreat to the background, this file is triggered. It has a corresponding relationship with the onFocas event.
6. Load file onLoad
This event is generated when the document is loaded. One function of onLoad is to detect the value of the cookie when a document is loaded for the first time and assign it a value with a variable so that it can be used by the source code.
7. Unload files onUnload
The onUnload event is triggered when the web page exits, and the status of the cookie can be updated.
The above is the event-driven content of the JavaScript tutorial. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!