站点工具

用户工具


====== 差别 ======

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
当让你封装一个事件代理函数时 [2023/02/08 19:04]
若愚 创建
当让你封装一个事件代理函数时 [2023/02/08 19:05] (当前版本)
若愚
行 14: 行 14:
   <div class="other">other</div>   <div class="other">other</div>
 </body> </body>
-<script>+<Script>
 function delegate(eventType, root, selector, handler) { function delegate(eventType, root, selector, handler) {
   root.onclick = function(e) {   root.onclick = function(e) {
行 27: 行 27:
   console.log(e.target.innerText)   console.log(e.target.innerText)
 }) })
-</script>+</Script>
 ``` ```
  
行 63: 行 63:
   <div class="other">other</div>   <div class="other">other</div>
 </body> </body>
-<script>+<Script>
 function delegate(eventType, root, selector, handler) { function delegate(eventType, root, selector, handler) {
   root.onclick = function(e) {   root.onclick = function(e) {
行 77: 行 77:
 }) })
 //点击button1 的 //点击button1 的
-</script>+</Script>
 ``` ```
  
行 90: 行 90:
   <div class="other">other</div>   <div class="other">other</div>
 </body> </body>
-<script>+<Script>
   function delegate(eventType, root, selector, handler) {   function delegate(eventType, root, selector, handler) {
     root.onclick = function(e) {     root.onclick = function(e) {
行 109: 行 109:
   })   })
  
-</script>+</Script>
 ``` ```
  
行 129: 行 129:
   <div class="other">other</div>   <div class="other">other</div>
 </body> </body>
-<script>+<Script>
 function delegate(eventType, root, selector, handler) { function delegate(eventType, root, selector, handler) {
   root.addEventListener(eventType, function(e) {   root.addEventListener(eventType, function(e) {
行 151: 行 151:
 })   })  
      
-</script>+</Script>
 ``` ```
  
若愚 · 2023/02/08 19:04 · 当让你封装一个事件代理函数时.1675854273.txt.gz