An ordinary event refers to an event that can be used for registration;
Event binding refers to registering an event on a specific element.
Popular Point says:
Normal event: Add a specific attribute (for example: onclick) to the HTML element;
Event binding: JS code gets the element by tag (ID tag Class), adding a specific method to the element ( for example: onclick);
Extended: Event listener AddEventListener event can bind multiple events and trigger
function (){};
<button onmouseover = " " ></button>
1, if the same element is bound two or more times the same type of event, then the subsequent binding will overwrite the previous binding
2. Dom Event Flow event capture Phase target element phase = Event Bubbling phase is not supported
AddEventListener
? If the same element is bound two or more times the same type of event, so the binding will be triggered sequentially
? Support for DOM event streams
The event binding parameter does not need to be on (in front of us)
AddEventListener ("click",function() {},true); // the event at this point is performed during the event bubbling phase
Compatibility processing
IE9 began to Ie11 Edge:addeventlistener
IE9 before: attachevent/detachevent
? Event type parameters need to be prefixed with on
? This approach only supports event bubbling and does not support event capture
Compare attachevent and AddEventListener:
- Attachevent only supports event bubbling AddEventListener supports both event bubbling and event capture
- Parameter: Attachevent event type requires on prefix, AddEventListener event type does not need an on prefix
- If you use Attachevent to bind multiple events to the target stage of an element, it is triggered in the reverse order of the binding order, and if you use AddEventListener to bind multiple events to the target stage of an element, it is triggered in the binding order
On the understanding of event binding and ordinary events in JS