freeCodeCamp/guide/chinese/miscellaneous/change-text-with-click-events/index.md

10 lines
385 B
Markdown
Raw Normal View History

---
title: Change Text with Click Events
localeTitle: 使用Click事件更改文本
---
当发生click事件时我们可以使用Ajax使用以下代码更新HTML元素
```
$(".message").html("Here is the message");
```
这告诉jQuery使用类`message`作为选择器为此更改HTML以使字符串提供我们还可以添加用引号括起来的自定义html元素。