Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common events in javascript

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what are the events commonly used in javascript". The editor shows you the operation process through actual cases, and the operation method is simple, fast and practical. I hope this article "what are the events commonly used in javascript" can help you solve the problem.

The common events in javascript are: 1, click events (onclick and ondblclick); 2, focus events (onblur and onfocus); 3, load events (onload); 4, mouse events; 5, keyboard events; 6, select and change events; 7, form events.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Events in JS:

Concept: some components trigger the execution of some code after some actions have been performed.

Event: some actions. Click, double click, the keyboard is pressed, the mouse is moved

Event source: component. Such as: button text input box.

Listener: code.

Register listeners: combine events, event sources, and listeners. When an event occurs on the event source, the execution of a listener code is triggered.

1. Common events

1) Click event:

Onclick: click event

Ondblclick: double-click event

2) focus event

Onblur: lose focus

Onfocus: the element gets focus.

3) load event:

Onload: a page or an image is loaded.

4) Mouse event:

The onmousedown mouse button is pressed.

The onmouseup mouse button is released.

The onmousemove mouse is moved.

Onmouseover mouse over an element.

Move the onmouseout mouse away from an element.

5) Keyboard events:

Onkeydown one of the keyboard keys is pressed.

One of the keyboard keys in onkeyup has been released.

One of the onkeypress keyboard keys is pressed and released.

6) Select and change events

The contents of the onchange domain have been changed.

The onselect text is selected.

7) form event:

The onsubmit confirmation button is clicked.

The onreset reset button is clicked.

2. Registration of events

3.1. What is the registration (binding) of events?

In fact, it is to tell the browser what action code to perform after the event response, called event registration or event binding.

3.2. Two ways to register events (static registration events and dynamic registration events)

Static registration of events: the event attribute of the html tag is directly assigned to the code after the event response, which is called static registration.

Function sayHello () {alert ("hello js!");}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report