--- id: 587d7fad367417b2b2512be2 title: Change Text with click Events challengeType: 6 forumTopicId: 301500 localeTitle: 通过单击事件更改文本 --- ## Description
当点击事件发生时,你可以使用 JavaScript 更新 HTML 元素。 例如,当用户点击 "Get Message" 按钮时,它将改变类名message元素的文本为 "Here is the message"。 通过在点击事件内添加以下代码实现: document.getElementsByClassName('message')[0].textContent="Here is the message";
## Instructions
onclick事件处理器中添加代码,改变message元素内的文字为 "Here is the message"。
## Tests
```yml tests: - text: 你的代码应该使用document.getElementsByClassName方法来选择类名为message的元素,然后将其innerHTML改为给定文字。 testString: assert(code.match(/document\s*\.getElementsByClassName\(\s*?('|")message\1\s*?\)\[0\]\s*\.textContent\s*?=\s*?('|")Here is the message\2/g)); ```
## Challenge Seed
```html

Cat Photo Finder

The message will go here

```
## Solution
```html

Cat Photo Finder

The message will go here

```