Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

事件冒泡 #40

Open
hoperyy opened this issue Jun 26, 2017 · 0 comments
Open

事件冒泡 #40

hoperyy opened this issue Jun 26, 2017 · 0 comments

Comments

@hoperyy
Copy link
Owner

hoperyy commented Jun 26, 2017

<div id="outer">
	<div id="inner">inner</div>
</div>
  • 标准的事件流是怎样的?

    标准的事件流是:根节点(document/html) --> 向下捕获 --> 目标元素 --> 向上冒泡到根节点(document/html)

    也就是说,标准的事件流,遵循的是事件捕获

  • 如果一个标签没有子标签,分别给该节点设置捕获和冒泡事件时,事件响应的先后顺序是怎样的?

    谁在前,先响应谁

  • 兼容写法

    标准浏览器:

    dom.addEventListener('click', function() {}, false);
    

    其中,第三个参数,如果为 true,则为捕获;否则为冒泡。

    IE 浏览器(10-)

    dom.attachEvent('onclick', function() {})
    

    这个方法在 IE11 已经被废弃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant