941 B

id, title, challengeType, forumTopicId
id title challengeType forumTopicId
587d7fad367417b2b2512be2 通过单击事件更改文本 6 301500

--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"。

--hints--

你的代码应该使用document.getElementsByClassName方法来选择类名为message的元素,然后将其innerHTML改为给定文字。

assert(
  code.match(
    /document\s*\.getElementsByClassName\(\s*?('|")message\1\s*?\)\[0\]\s*\.textContent\s*?=\s*?('|")Here is the message\2/g
  )
);

--solutions--