freeCodeCamp/guide/chinese/certifications/front-end-libraries/jquery/target-html-elements-with-s.../index.md

29 lines
769 B
Markdown
Raw Normal View History

---
title: Target HTML Elements with Selectors Using jQuery
localeTitle: 使用选择器使用jQuery定位HTML元素
---
* JQuery选择器允许您选择和操作HTML元素。
* 这些选择器以美元符号和括号开头:$
* 您可以根据名称ID类型属性属性值等“查找”或选择HTML元素。
## 例
```javascipt
//You can select all <p> elements on a page like this = $("p")
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
```
## 解
```javascript
<script>
$(document).ready(function() {
$("button").addClass("animated bounce"); // We are selecting the button elements and adding "animated bounce" class to them.
});
</script>
```