Skip to content

translate: 2-ui/1-document/07-modifying-document #1077

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

Merged
merged 6 commits into from
Jul 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 2-ui/1-document/07-modifying-document/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ div.innerHTML = "<strong>Hi there!</strong> You've read an important message.";

## 插入方法

为了让 `div` 显示出来,我们需要将其插入到 `document` 中的某处。例如,into `<body>` element, referenced by `document.body`.
为了让 `div` 显示出来,我们需要将其插入到 `document` 中的某处。例如,通过 `document.body` 将其插入到 `<body>` 元素里。

对此有一个特殊的方法 `append`:`document.body.append(div)`。

Expand Down Expand Up @@ -187,10 +187,10 @@ after

该方法的第一个参数是代码字(code word),指定相对于 `elem` 的插入位置。必须为以下之一:

- `"beforebegin"` — 将 `html` 插入到 `elem` 前插入
- `"beforebegin"` — 将 `html` 插入到 `elem` 之前
- `"afterbegin"` — 将 `html` 插入到 `elem` 开头,
- `"beforeend"` — 将 `html` 插入到 `elem` 末尾,
- `"afterend"` — 将 `html` 插入到 `elem`
- `"afterend"` — 将 `html` 插入到 `elem` 之后

第二个参数是 HTML 字符串,该字符串会被“作为 HTML” 插入。

Expand Down