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

10 lines
385 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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