| 方法 | addClass() | attr() |
|---|---|---|
| 用途 | 追加样式 | 设置样式 |
| 对同一个网页元素操作 | <p>test<p> |
|
| 第1次使用方法 | $("p").addClass("high"); |
$("p").attr("class","high"); |
| 第1次结果 | <p class="high">test<p> |
|
| 再次使用方法 | $("p").addClass("another"); |
$("p").attr("class","another"); |
| 最终结果 | <p class="high another">test<p> |
<p class="another">test<p> |