---
title: "四、选择器--位置选择器"
author: "youyang_java"
date: "2013-03-24T20:14:46Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2013-03-29T11:42:02Z"
id: 1835780
url: "https://youyang-java.iteye.com/blog/1835780"
---

![](http://dl.iteye.com/upload/attachment/0082/1259/db349b41-991c-3cc9-b32d-59facbe13f1c.bmp)  
![](http://dl.iteye.com/upload/attachment/0082/1261/1ba9e972-ebe0-3e06-8132-89463cd25cb1.bmp)  
 

             //页面中最先匹配的某个元素  
            //alert($("li:first").html());  
            //页面中最后匹配的元素  
            //$("li:last").css("background","#f00");  
            //获取满足要求的第一个li  
            //$(".myList&gt;li li:first-child").css("background","#f00");  
            //获取没有兄弟节点的ul  
            //alert($("ul:only-child").length);

            nth-child(N)

            用我们家族关系来形象地说，nth-child(N)选取的是在我们的家族中所有的老N的集合。

             
![](http://dl.iteye.com/upload/attachment/0082/3897/b46e9172-c9a5-364e-8834-0d14ea5da0a8.jpg)