From b069e3484af15293332be2303669a634678285c5 Mon Sep 17 00:00:00 2001 From: "Edward.Wu" Date: Fri, 29 Sep 2017 14:45:52 +0900 Subject: [PATCH 1/2] translate 02-bubbling-and-capturing article --- .../02-bubbling-and-capturing/article.md | 164 +++++++++--------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/2-ui/2-events/02-bubbling-and-capturing/article.md b/2-ui/2-events/02-bubbling-and-capturing/article.md index a3ee986d..54f4eaed 100644 --- a/2-ui/2-events/02-bubbling-and-capturing/article.md +++ b/2-ui/2-events/02-bubbling-and-capturing/article.md @@ -1,8 +1,8 @@ -# Bubbling and capturing +# 事件冒泡(bubbling)和事件捕获(capturing) -Let's start with an example. +让我们先看一个例子。 -This handler is assigned to `
`, but also runs if you click any nested tag like `` or ``: +下面的事件处理器被绑定到 `
` 元素,但是如果你点击任何嵌套的标签,如 `` 或者是 ``,依然会执行事件: ```html autorun height=60
@@ -10,15 +10,15 @@ This handler is assigned to `
`, but also runs if you click any nested tag l
``` -Isn't it a bit strange? Why the handler on `
` runs if the actual click was on ``? +这是不是有点奇怪?为什么实际上我们点击的是 ``,然而绑定在 `
` 上事件被执行了呢? -## Bubbling +## 事件冒泡(Bubbling) -The bubbling principle is simple. +事件冒泡的原理其实很简单。 -**When an event happens on an element, it first runs the handlers on it, then on its parent, then all the way up on other ancestors.** +**当在某个元素上发生事件时,首先执行绑定在该元素上的事件处理器,然后执行其父节点上的,然后以此类推,执行其他祖先节点上的事件处理器。** -Let's say, we have 3 nested elements `FORM > DIV > P` with a handler on each of them: +假设我们有3个嵌套元素 `FORM > DIV > P`,每个元素都有一个处理函数: ```html run autorun