freeCodeCamp/guide/chinese/miscellaneous/change-the-css-of-an-elemen.../index.md

16 lines
348 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 the CSS of an Element Using jQuery
localeTitle: 使用jQuery更改元素的CSS
---
我们也可以使用jQuery直接更改HTML元素的CSS。
Query有一个名为`.css()`的函数它允许您更改元素的CSS。
```
<script>
$(document).ready(function() {
$("#target1").css("color", "red");
});
</script>
```