1. Bubbling events
Browser event models are divided into two types: capturing events and bubbling events. Since IE does not support capturing events, the following mainly uses bubbling events as an explanation.
(Dubbed bubbling) Bubbling means that events are triggered one by one from the most specific event to the least specific event.
By the way, here is a reminder of capturing events, whose order is exactly the opposite of bubbling events.
2. Event monitoring
An event requires a function to respond. This type of function is usually called an event handler. From another perspective, these functions are monitoring whether an event occurs in real time. They are usually called event listening functions ( enevt listener), the event listening function varies greatly between different browsers.i. Universal listening methods, such as using the onclick method, almost every tag supports this method. And the browser compatibility is very high
Accounting for behavior, event separation.
Generally, the following methods are used for monitoring
ii.Listening method in IE
In early IE browsers, each element has two methods to handle time monitoring.
They are attachEvent() and detachEnevt() respectively.
As can be seen from their function names, attachEnevt() is a function used to add event processing to an element, while detachEvent() is used to delete the listening function on the element. Their syntax is as follows:
[object].detachEvent("enevt_handler","fnHandler");
Among them, enevt_handler represents commonly used onclick, onload, onmouseover, etc.
fnHandler is the name of the listening function.
In the event in the previous section, you can use the attachEvent() method instead of adding a listening function. When you click once, you can use detachEvent() to delete the listening function so that it will not be executed after the next click.
3. Standard DOM event monitoring
Compared with the two methods of ie, the standard DOM also uses two methods to add and delete listening functions respectively. That is addEventListener(), and removeEventListener()
Copy code
Copy code