Cara menggunakan javascript follow mouse effect

The

<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="style.css">
</head>

<body>

  <div id="container">
    <div class="smiley-green">
      <div class="left-eye"></div>
      <div class="right-eye"></div>
      <div class="smile"></div>
    </div>

    <div class="smiley-yellow">
      <div class="left-eye"></div>
      <div class="right-eye"></div>
      <div class="smile"></div>
    </div>

    <div class="smiley-red">
      <div class="left-eye"></div>
      <div class="right-eye"></div>
      <div class="smile"></div>
    </div>
  </div>

  <textarea id="log">Events will show up here!
</textarea>

  <script src="script.js"></script>

</body>
</html>
2 event occurs when a mouse pointer comes over an element, and
<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="style.css">
</head>

<body>

  <div id="container">
    <div class="smiley-green">
      <div class="left-eye"></div>
      <div class="right-eye"></div>
      <div class="smile"></div>
    </div>

    <div class="smiley-yellow">
      <div class="left-eye"></div>
      <div class="right-eye"></div>
      <div class="smile"></div>
    </div>

    <div class="smiley-red">
      <div class="left-eye"></div>
      <div class="right-eye"></div>
      <div class="smile"></div>
    </div>
  </div>

  <textarea id="log">Events will show up here!
</textarea>

  <script src="script.js"></script>

</body>
</html>
3 – when it leaves.

Show

    These events are special, because they have property

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4. This property complements
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    5. When a mouse leaves one element for another, one of them becomes
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    5, and the other one –
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4.

    For

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2:

    • <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      9 – is the element where the mouse came over.
    • let parent = document.getElementById('parent');
      parent.onmouseover = parent.onmouseout = parent.onmousemove = handler;
      
      function handler(event) {
        let type = event.type;
        while (type.length < 11) type += ' ';
      
        log(type + " target=" + event.target.id)
        return false;
      }
      
      
      function clearText() {
        text.value = "";
        lastMessage = "";
      }
      
      let lastMessageTime = 0;
      let lastMessage = "";
      let repeatCounter = 1;
      
      function log(message) {
        if (lastMessageTime == 0) lastMessageTime = new Date();
      
        let time = new Date();
      
        if (time - lastMessageTime > 500) {
          message = '------------------------------\n' + message;
        }
      
        if (message === lastMessage) {
          repeatCounter++;
          if (repeatCounter == 2) {
            text.value = text.value.trim() + ' x 2\n';
          } else {
            text.value = text.value.slice(0, text.value.lastIndexOf('x') + 1) + repeatCounter + "\n";
          }
      
        } else {
          repeatCounter = 1;
          text.value += message + "\n";
        }
      
        text.scrollTop = text.scrollHeight;
      
        lastMessageTime = time;
        lastMessage = message;
      }
      0 – is the element from which the mouse came (
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      4 →
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      5).

    For

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3 the reverse:

    • <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      9 – is the element that the mouse left.
    • let parent = document.getElementById('parent');
      parent.onmouseover = parent.onmouseout = parent.onmousemove = handler;
      
      function handler(event) {
        let type = event.type;
        while (type.length < 11) type += ' ';
      
        log(type + " target=" + event.target.id)
        return false;
      }
      
      
      function clearText() {
        text.value = "";
        lastMessage = "";
      }
      
      let lastMessageTime = 0;
      let lastMessage = "";
      let repeatCounter = 1;
      
      function log(message) {
        if (lastMessageTime == 0) lastMessageTime = new Date();
      
        let time = new Date();
      
        if (time - lastMessageTime > 500) {
          message = '------------------------------\n' + message;
        }
      
        if (message === lastMessage) {
          repeatCounter++;
          if (repeatCounter == 2) {
            text.value = text.value.trim() + ' x 2\n';
          } else {
            text.value = text.value.slice(0, text.value.lastIndexOf('x') + 1) + repeatCounter + "\n";
          }
      
        } else {
          repeatCounter = 1;
          text.value += message + "\n";
        }
      
        text.scrollTop = text.scrollHeight;
      
        lastMessageTime = time;
        lastMessage = message;
      }
      0 – is the new under-the-pointer element, that mouse left for (
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      5 →
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      4).

    In the example below each face and its features are separate elements. When you move the mouse, you can see mouse events in the text area.

    Each event has the information about both

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    5 and
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4:

    Result

    script.js

    style.css

    index.html

    container.onmouseover = container.onmouseout = handler;
    
    function handler(event) {
    
      function str(el) {
        if (!el) return "null"
        return el.className || el.tagName;
      }
    
      log.value += event.type + ':  ' +
        'target=' + str(event.target) +
        ',  relatedTarget=' + str(event.relatedTarget) + "\n";
      log.scrollTop = log.scrollHeight;
    
      if (event.type == 'mouseover') {
        event.target.style.background = 'pink'
      }
      if (event.type == 'mouseout') {
        event.target.style.background = ''
      }
    }

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4 can be
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    1

    The

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4 property can be
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    1.

    That’s normal and just means that the mouse came not from another element, but from out of the window. Or that it left the window.

    We should keep that possibility in mind when using

    let parent = document.getElementById('parent');
    parent.onmouseover = parent.onmouseout = parent.onmousemove = handler;
    
    function handler(event) {
      let type = event.type;
      while (type.length < 11) type += ' ';
    
      log(type + " target=" + event.target.id)
      return false;
    }
    
    
    function clearText() {
      text.value = "";
      lastMessage = "";
    }
    
    let lastMessageTime = 0;
    let lastMessage = "";
    let repeatCounter = 1;
    
    function log(message) {
      if (lastMessageTime == 0) lastMessageTime = new Date();
    
      let time = new Date();
    
      if (time - lastMessageTime > 500) {
        message = '------------------------------\n' + message;
      }
    
      if (message === lastMessage) {
        repeatCounter++;
        if (repeatCounter == 2) {
          text.value = text.value.trim() + ' x 2\n';
        } else {
          text.value = text.value.slice(0, text.value.lastIndexOf('x') + 1) + repeatCounter + "\n";
        }
    
      } else {
        repeatCounter = 1;
        text.value += message + "\n";
      }
    
      text.scrollTop = text.scrollHeight;
    
      lastMessageTime = time;
      lastMessage = message;
    }
    0 in our code. If we access
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    5, then there will be an error.

    The

    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    6 event triggers when the mouse moves. But that doesn’t mean that every pixel leads to an event.

    The browser checks the mouse position from time to time. And if it notices changes then triggers the events.

    That means that if the visitor is moving the mouse very fast then some DOM-elements may be skipped:

    If the mouse moves very fast from

    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    7 to
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    8 elements as painted above, then intermediate
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    9 elements (or some of them) may be skipped. The
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3 event may trigger on
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    7 and then immediately
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2 on
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    8.

    That’s good for performance, because there may be many intermediate elements. We don’t really want to process in and out of each one.

    On the other hand, we should keep in mind that the mouse pointer doesn’t “visit” all elements along the way. It can “jump”.

    In particular, it’s possible that the pointer jumps right inside the middle of the page from out of the window. In that case

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4 is
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    1, because it came from “nowhere”:

    You can check it out “live” on a teststand below.

    Its HTML has two nested elements: the

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent">parent
        <div id="child">child</div>
      </div>
      <textarea id="text"></textarea>
      <input onclick="clearText()" value="Clear" type="button">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    6 is inside the
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent">parent
        <div id="child">child</div>
      </div>
      <textarea id="text"></textarea>
      <input onclick="clearText()" value="Clear" type="button">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    7. If you move the mouse fast over them, then maybe only the child div triggers events, or maybe the parent one, or maybe there will be no events at all.

    Also move the pointer into the child

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent">parent
        <div id="child">child</div>
      </div>
      <textarea id="text"></textarea>
      <input onclick="clearText()" value="Clear" type="button">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    8, and then move it out quickly down through the parent one. If the movement is fast enough, then the parent element is ignored. The mouse will cross the parent element without noticing it.

    Result

    script.js

    style.css

    index.html

    let parent = document.getElementById('parent');
    parent.onmouseover = parent.onmouseout = parent.onmousemove = handler;
    
    function handler(event) {
      let type = event.type;
      while (type.length < 11) type += ' ';
    
      log(type + " target=" + event.target.id)
      return false;
    }
    
    
    function clearText() {
      text.value = "";
      lastMessage = "";
    }
    
    let lastMessageTime = 0;
    let lastMessage = "";
    let repeatCounter = 1;
    
    function log(message) {
      if (lastMessageTime == 0) lastMessageTime = new Date();
    
      let time = new Date();
    
      if (time - lastMessageTime > 500) {
        message = '------------------------------\n' + message;
      }
    
      if (message === lastMessage) {
        repeatCounter++;
        if (repeatCounter == 2) {
          text.value = text.value.trim() + ' x 2\n';
        } else {
          text.value = text.value.slice(0, text.value.lastIndexOf('x') + 1) + repeatCounter + "\n";
        }
    
      } else {
        repeatCounter = 1;
        text.value += message + "\n";
      }
    
      text.scrollTop = text.scrollHeight;
    
      lastMessageTime = time;
      lastMessage = message;
    }

    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent">parent
        <div id="child">child</div>
      </div>
      <textarea id="text"></textarea>
      <input onclick="clearText()" value="Clear" type="button">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>

    If

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2 triggered, there must be
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3

    In case of fast mouse movements, intermediate elements may be ignored, but one thing we know for sure: if the pointer “officially” entered an element (

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2 event generated), then upon leaving it we always get
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3.

    An important feature of

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3 – it triggers, when the pointer moves from an element to its descendant, e.g. from
    <div id="parent">
      <div id="child">...</div>
    </div>
    4 to
    <div id="parent">
      <div id="child">...</div>
    </div>
    5 in this HTML:

    <div id="parent">
      <div id="child">...</div>
    </div>

    If we’re on

    <div id="parent">
      <div id="child">...</div>
    </div>
    4 and then move the pointer deeper into
    <div id="parent">
      <div id="child">...</div>
    </div>
    5, we get
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3 on
    <div id="parent">
      <div id="child">...</div>
    </div>
    4!

    That may seem strange, but can be easily explained.

    According to the browser logic, the mouse cursor may be only over a single element at any time – the most nested one and top by z-index.

    So if it goes to another element (even a descendant), then it leaves the previous one.

    Please note another important detail of event processing.

    The

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2 event on a descendant bubbles up. So, if
    <div id="parent">
      <div id="child">...</div>
    </div>
    4 has
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2 handler, it triggers:

    You can see that very well in the example below:

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent">parent
        <div id="child">child</div>
      </div>
      <textarea id="text"></textarea>
      <input onclick="clearText()" value="Clear" type="button">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    6 is inside the
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent">parent
        <div id="child">child</div>
      </div>
      <textarea id="text"></textarea>
      <input onclick="clearText()" value="Clear" type="button">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    7. There are
    function mouselog(event) {
      let d = new Date();
      text.value += `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} | ${event.type} [target: ${event.target.id}]\n`.replace(/(:|^)(\d\D)/, '$10$2');
      text.scrollTop = text.scrollHeight;
    }
    5 handlers on
    <div id="parent">
      <div id="child">...</div>
    </div>
    4 element that output event details.

    If you move the mouse from

    <div id="parent">
      <div id="child">...</div>
    </div>
    4 to
    <div id="parent">
      <div id="child">...</div>
    </div>
    5, you see two events on
    <div id="parent">
      <div id="child">...</div>
    </div>
    4:

    1. #parent {
        background: #99C0C3;
        width: 160px;
        height: 120px;
        position: relative;
      }
      
      #child {
        background: #FFDE99;
        width: 50%;
        height: 50%;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
      
      textarea {
        height: 140px;
        width: 300px;
        display: block;
      }
      0 (left the parent), then
    2. #parent {
        background: #99C0C3;
        width: 160px;
        height: 120px;
        position: relative;
      }
      
      #child {
        background: #FFDE99;
        width: 50%;
        height: 50%;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
      
      textarea {
        height: 140px;
        width: 300px;
        display: block;
      }
      1 (came to the child, bubbled).

    Result

    script.js

    style.css

    index.html

    function mouselog(event) {
      let d = new Date();
      text.value += `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} | ${event.type} [target: ${event.target.id}]\n`.replace(/(:|^)(\d\D)/, '$10$2');
      text.scrollTop = text.scrollHeight;
    }

    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>

    As shown, when the pointer moves from

    <div id="parent">
      <div id="child">...</div>
    </div>
    4 element to
    <div id="parent">
      <div id="child">...</div>
    </div>
    5, two handlers trigger on the parent element:
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3 and
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2:

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    0

    If we don’t examine

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    9 inside the handlers, then it may seem that the mouse pointer left
    <div id="parent">
      <div id="child">...</div>
    </div>
    4 element, and then immediately came back over it.

    But that’s not the case! The pointer is still over the parent, it just moved deeper into the child element.

    If there are some actions upon leaving the parent element, e.g. an animation runs in

    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    8, we usually don’t want it when the pointer just goes deeper into
    <div id="parent">
      <div id="child">...</div>
    </div>
    4.

    To avoid it, we can check

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    4 in the handler and, if the mouse is still inside the element, then ignore such event.

    Alternatively we can use other events:

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    1 and
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    2, that we’ll be covering now, as they don’t have such problems.

    Events

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    3 are like
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    4. They trigger when the mouse pointer enters/leaves the element.

    But there are two important differences:

    1. Transitions inside the element, to/from descendants, are not counted.
    2. Events
      <!doctype html>
      <html>
      
      <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
          <div id="child">child</div>
        </div>
      
        <textarea id="text"></textarea>
        <input type="button" onclick="text.value=''" value="Clear">
      
        <script src="script.js"></script>
      
      </body>
      
      </html>
      3 do not bubble.

    These events are extremely simple.

    When the pointer enters an element –

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    1 triggers. The exact location of the pointer inside the element or its descendants doesn’t matter.

    When the pointer leaves an element –

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    2 triggers.

    This example is similar to the one above, but now the top element has

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    3 instead of
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    4.

    As you can see, the only generated events are the ones related to moving the pointer in and out of the top element. Nothing happens when the pointer goes to the child and back. Transitions between descendants are ignored

    Result

    script.js

    style.css

    index.html

    function mouselog(event) {
      let d = new Date();
      text.value += `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} | ${event.type} [target: ${event.target.id}]\n`.replace(/(:|^)(\d\D)/, '$10$2');
      text.scrollTop = text.scrollHeight;
    }

    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    3

    Events

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    00 are very simple and easy to use. But they do not bubble. So we can’t use event delegation with them.

    Imagine we want to handle mouse enter/leave for table cells. And there are hundreds of cells.

    The natural solution would be – to set the handler on

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    01 and process events there. But
    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    00 don’t bubble. So if such event happens on
    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    03, then only a handler on that
    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    03 is able to catch it.

    Handlers for

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    00 on
    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    01 only trigger when the pointer enters/leaves the table as a whole. It’s impossible to get any information about transitions inside it.

    So, let’s use

    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    4.

    Let’s start with simple handlers that highlight the element under mouse:

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    4

    Here they are in action. As the mouse travels across the elements of this table, the current one is highlighted:

    Result

    script.js

    style.css

    index.html

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    5

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    6

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    7

    In our case we’d like to handle transitions between table cells

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    03: entering a cell and leaving it. Other transitions, such as inside the cell or outside of any cells, don’t interest us. Let’s filter them out.

    Here’s what we can do:

    • Remember the currently highlighted
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      03 in a variable, let’s call it
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      10.
    • On
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      2 – ignore the event if we’re still inside the current
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      03.
    • On
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      3 – ignore if we didn’t leave the current
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      03.

    Here’s an example of code that accounts for all possible situations:

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    8

    Once again, the important features are:

    1. It uses event delegation to handle entering/leaving of any
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      03 inside the table. So it relies on
      function mouselog(event) {
        let d = new Date();
        text.value += `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} | ${event.type} [target: ${event.target.id}]\n`.replace(/(:|^)(\d\D)/, '$10$2');
        text.scrollTop = text.scrollHeight;
      }
      5 instead of
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      00 that don’t bubble and hence allow no delegation.
    2. Extra events, such as moving between descendants of
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      03 are filtered out, so that
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      19 runs only if the pointer leaves or enters
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      03 as a whole.

    Here’s the full example with all details:

    Result

    script.js

    style.css

    index.html

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    8

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    6

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    7

    Try to move the cursor in and out of table cells and inside them. Fast or slow – doesn’t matter. Only

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    03 as a whole is highlighted, unlike the example before.

    We covered events

    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    2,
    <!DOCTYPE HTML>
    <html>
    
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="container">
        <div class="smiley-green">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-yellow">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
    
        <div class="smiley-red">
          <div class="left-eye"></div>
          <div class="right-eye"></div>
          <div class="smile"></div>
        </div>
      </div>
    
      <textarea id="log">Events will show up here!
    </textarea>
    
      <script src="script.js"></script>
    
    </body>
    </html>
    3,
    #parent {
      background: #99C0C3;
      width: 160px;
      height: 120px;
      position: relative;
    }
    
    #child {
      background: #FFDE99;
      width: 50%;
      height: 50%;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    
    textarea {
      height: 140px;
      width: 300px;
      display: block;
    }
    6,
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    1 and
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
    
      <div id="parent" onmouseover="mouselog(event)" onmouseout="mouselog(event)">parent
        <div id="child">child</div>
      </div>
    
      <textarea id="text"></textarea>
      <input type="button" onclick="text.value=''" value="Clear">
    
      <script src="script.js"></script>
    
    </body>
    
    </html>
    2.

    These things are good to note:

    • A fast mouse move may skip intermediate elements.
    • Events
      function mouselog(event) {
        let d = new Date();
        text.value += `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} | ${event.type} [target: ${event.target.id}]\n`.replace(/(:|^)(\d\D)/, '$10$2');
        text.scrollTop = text.scrollHeight;
      }
      5 and
      body,
      html {
        margin: 0;
        padding: 0;
      }
      
      #container {
        border: 1px solid brown;
        padding: 10px;
        width: 330px;
        margin-bottom: 5px;
        box-sizing: border-box;
      }
      
      #log {
        height: 120px;
        width: 350px;
        display: block;
        box-sizing: border-box;
      }
      
      [class^="smiley-"] {
        display: inline-block;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        margin-right: 20px;
      }
      
      .smiley-green {
        background: #a9db7a;
        border: 5px solid #92c563;
        position: relative;
      }
      
      .smiley-green .left-eye {
        width: 18%;
        height: 18%;
        background: #84b458;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-green .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #84b458;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-green .smile {
        position: absolute;
        top: 67%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-green .smile:after,
      .smiley-green .smile:before {
        content: "";
        position: absolute;
        top: -50%;
        left: 0%;
        border-radius: 50%;
        background: #84b458;
        height: 100%;
        width: 97%;
      }
      
      .smiley-green .smile:after {
        background: #84b458;
        height: 80%;
        top: -40%;
        left: 0%;
      }
      
      .smiley-yellow {
        background: #eed16a;
        border: 5px solid #dbae51;
        position: relative;
      }
      
      .smiley-yellow .left-eye {
        width: 18%;
        height: 18%;
        background: #dba652;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-yellow .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #dba652;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-yellow .smile {
        position: absolute;
        top: 67%;
        left: 19%;
        width: 65%;
        height: 14%;
        background: #dba652;
        overflow: hidden;
        border-radius: 8px;
      }
      
      .smiley-red {
        background: #ee9295;
        border: 5px solid #e27378;
        position: relative;
      }
      
      .smiley-red .left-eye {
        width: 18%;
        height: 18%;
        background: #d96065;
        position: relative;
        top: 29%;
        left: 22%;
        border-radius: 50%;
        float: left;
      }
      
      .smiley-red .right-eye {
        width: 18%;
        height: 18%;
        border-radius: 50%;
        position: relative;
        background: #d96065;
        top: 29%;
        right: 22%;
        float: right;
      }
      
      .smiley-red .smile {
        position: absolute;
        top: 57%;
        left: 16.5%;
        width: 70%;
        height: 20%;
        overflow: hidden;
      }
      
      .smiley-red .smile:after,
      .smiley-red .smile:before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0%;
        border-radius: 50%;
        background: #d96065;
        height: 100%;
        width: 97%;
      }
      
      .smiley-red .smile:after {
        background: #d96065;
        height: 80%;
        top: 60%;
        left: 0%;
      }
      00 have an additional property:
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      4. That’s the element that we are coming from/to, complementary to
      <!DOCTYPE HTML>
      <html>
      
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="style.css">
      </head>
      
      <body>
      
        <div id="container">
          <div class="smiley-green">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-yellow">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
      
          <div class="smiley-red">
            <div class="left-eye"></div>
            <div class="right-eye"></div>
            <div class="smile"></div>
          </div>
        </div>
      
        <textarea id="log">Events will show up here!
      </textarea>
      
        <script src="script.js"></script>
      
      </body>
      </html>
      5.

    Events

    function mouselog(event) {
      let d = new Date();
      text.value += `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} | ${event.type} [target: ${event.target.id}]\n`.replace(/(:|^)(\d\D)/, '$10$2');
      text.scrollTop = text.scrollHeight;
    }
    5 trigger even when we go from the parent element to a child element. The browser assumes that the mouse can be only over one element at one time – the deepest one.

    Events

    body,
    html {
      margin: 0;
      padding: 0;
    }
    
    #container {
      border: 1px solid brown;
      padding: 10px;
      width: 330px;
      margin-bottom: 5px;
      box-sizing: border-box;
    }
    
    #log {
      height: 120px;
      width: 350px;
      display: block;
      box-sizing: border-box;
    }
    
    [class^="smiley-"] {
      display: inline-block;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      margin-right: 20px;
    }
    
    .smiley-green {
      background: #a9db7a;
      border: 5px solid #92c563;
      position: relative;
    }
    
    .smiley-green .left-eye {
      width: 18%;
      height: 18%;
      background: #84b458;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-green .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #84b458;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-green .smile {
      position: absolute;
      top: 67%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-green .smile:after,
    .smiley-green .smile:before {
      content: "";
      position: absolute;
      top: -50%;
      left: 0%;
      border-radius: 50%;
      background: #84b458;
      height: 100%;
      width: 97%;
    }
    
    .smiley-green .smile:after {
      background: #84b458;
      height: 80%;
      top: -40%;
      left: 0%;
    }
    
    .smiley-yellow {
      background: #eed16a;
      border: 5px solid #dbae51;
      position: relative;
    }
    
    .smiley-yellow .left-eye {
      width: 18%;
      height: 18%;
      background: #dba652;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-yellow .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #dba652;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-yellow .smile {
      position: absolute;
      top: 67%;
      left: 19%;
      width: 65%;
      height: 14%;
      background: #dba652;
      overflow: hidden;
      border-radius: 8px;
    }
    
    .smiley-red {
      background: #ee9295;
      border: 5px solid #e27378;
      position: relative;
    }
    
    .smiley-red .left-eye {
      width: 18%;
      height: 18%;
      background: #d96065;
      position: relative;
      top: 29%;
      left: 22%;
      border-radius: 50%;
      float: left;
    }
    
    .smiley-red .right-eye {
      width: 18%;
      height: 18%;
      border-radius: 50%;
      position: relative;
      background: #d96065;
      top: 29%;
      right: 22%;
      float: right;
    }
    
    .smiley-red .smile {
      position: absolute;
      top: 57%;
      left: 16.5%;
      width: 70%;
      height: 20%;
      overflow: hidden;
    }
    
    .smiley-red .smile:after,
    .smiley-red .smile:before {
      content: "";
      position: absolute;
      top: 50%;
      left: 0%;
      border-radius: 50%;
      background: #d96065;
      height: 100%;
      width: 97%;
    }
    
    .smiley-red .smile:after {
      background: #d96065;
      height: 80%;
      top: 60%;
      left: 0%;
    }
    00 are different in that aspect: they only trigger when the mouse comes in and out the element as a whole. Also they do not bubble.