# 자식 요소 필터 선택자

### 자식 요소 필터 선택자

![](https://1686368321-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MJPDmBW1ppF03ulXNry%2F-MJUT7P-Kj7RRCyzUtZe%2F-MJUVclV89OqowZi_qA8%2Fimage.png?alt=media\&token=3a6f1560-290f-4455-9b87-f57715457d1d)

```javascript
$("li:first").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"}); 
$("li:first-child").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:last").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:last-child").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:nth-child").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:nth-child(4)").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:nth-child(4n)").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:nth-child(2n+1)").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:nth-child(odd)").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:nth-child(even)").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
$("li:only-child").css({backgroundColor:"#f44336", border:"1px dashed #303f9f", color: "#fff"});
```
