SOURCE

console 命令行工具 X clear

                    
>
console
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>监听器</title>
</head>
<body>
  <table id="outside">
    <tr><td id="t1">one</td></tr>
    <tr><td id="t2">1</td></tr>
  </table>

  <script>
    (function() {
      // 添加函数
      const modifyText = (text) => {
        const t2 = document.querySelector('#t2'); //获取点击的元素属性
        if (t2.firstChild.nodeValue === text) {
          t2.firstChild.nodeValue = '1111';
        } else {
          t2.firstChild.nodeValue = text;
        }
      }
      // 给 Table 添加事件监听器
      const element = document.querySelector('#outside');
      element.addEventListener('click', function() { modifyText('four') }, false);
    })()

   
  </script>
</body>
</html>

本项目引用的自定义外部资源