DOM events - level

DOM event 0-3

  DOM event because of their different levels achieved in different ways, have their own characteristics.

  0: type of event is to provide relevant properties on dom element, js program through these specific types of properties registered event handlers.

    Characteristics: An element of the same type of event can only register an event handler.

// can be associated with the properties of an element node and to register event handlers 
<div class = "box" onclick = "alert ( 'box is clicked')"> X </ div> 
document.getElementsByClassName ( "Box") [0] .onclick = function () { 
  the console.log ( "Hello Box" ); 
}

  Level 1: none at all.

  Level 2: DOM element provided on a common approach to registration call to the elements specified type of event handler, and specify the mode of transmission of the event. Most browsers: addeventListener (event, listener, useCaptrue) IE11 the following: attachEvent (event, listener)

    Features: with the same type of event on an element can register multiple handlers. According to the order of registration trigger event is triggered.

  Level 3: Expansion in level 2.

Guess you like

Origin www.cnblogs.com/keliguicang/p/10994363.html