addEventListener如何在后台运行?

编程入门 行业动态 更新时间:2024-10-25 04:22:23
本文介绍了addEventListener如何在后台运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 var elem=document.getElementById('mydiv'); elem.addEventListener('click',function(){...});

执行以上代码后, elem 为 HTMLDivElement 界面的实例。我的大问题是addEventListener()方法的作用是什么。它在哪个DOM对象中注册侦听器以及它如何进行监听(它更改了这些DOM对象的哪些属性)。换句话说,我想知道 elem 如何得知侦听器的添加,它的哪些属性(所有这些属性都属于其原型链)会受到影响。例如,我知道Event.prototype具有关键属性,例如 type , target ;但是我无法用 elem ...

After execution of the above code elem is an instance of HTMLDivElement interface. My big question is what exactly addEventListener() method does. In which DOM objects does it register the listener and how it does that(which properties of these DOM objects it changes). In other words, I'd like to know how elem is informed about the addition of a listener, which of its properties(all of them down to its prototype chain) are affected. For example I know that Event.prototype has crucial properties like type, target; however I cannot "connect" them with elem...

连接它们,我不想找到哪个事件监听器附加到上述DOM节点。我想知道内部程序。

I do not want to find which event listeners are attached to the above DOM node. I want to know the inner procedures.

谢谢

推荐答案

执行上述代码后,elem是 HTMLDivElement 接口的实例。我的大问题是 addEventListener()方法的作用是什么。

After execution of the above code elem is an instance of HTMLDivElement interface. My big question is what exactly addEventListener() method does.

它在哪个DOM对象中注册侦听器

In which DOM objects does it register the listener

在调用 addEventListener 的DOM元素上。 (当然,子元素上的事件可能会冒出来)。

On the DOM element on which addEventListener was called. (Of course, events on sub-elements could bubble up).

以及它是如何做到的(这些DOM对象的属性会改变)

and how it does that (which properties of these DOM objects it changes)

这是内部实现的详细信息。它不会更改DOM对象的用户可见属性。

How it does that is an internal implementation detail. It changes no user-visible properties of the DOM object.

换句话说,我想知道如何告知elem有关添加侦听器的信息。

In other words, I'd like to know how elem is informed about the addition of a listener

不是。

它的哪些属性(全部下降)

which of its properties (all of them down to its prototype chain) are affected

都不受影响。

例如我知道Event.prototype具有至关重要的属性,例如类型,目标;但是我不能连接它们带有元素...

For example I know that Event.prototype has crucial properties like type, target; however I cannot "connect" them with elem...

这些是 Event 的属性,与 elem 。

更多推荐

addEventListener如何在后台运行?

本文发布于:2023-11-27 10:16:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637662.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后台   如何在   addEventListener

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!