Files
freeCodeCamp/guide/chinese/jquery/jquery-html-method/index.md
2018-10-16 21:32:40 +05:30

40 lines
628 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: HTML Method
localeTitle: HTML方法
---
# HTML方法
Jquery `.html()`方法获取HTML元素的内容或设置HTML元素的内容。
## 入门
要返回HTML元素的内容请使用以下语法
```javascript
$('selector').html();
```
例如:
```javascript
$('#example').html();
```
## 设置
要设置HTML元素的内容请使用以下语法
```javascript
$('selector').html(content);
```
例如:
```javascript
$('p').html('Hello World!');
```
这会将所有`<p>`元素的内容设置为Hello World
### 更多信息
[W3Schools的](https://www.w3schools.com/jquery/html_html.asp)