1、:last:获取匹配的最后个元素
2、示例
(1)源码
last.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>:last选择器</title>
<script type="text/javascript" src="jquery-2.0.3.js"></script>
<style type="text/css">
body{
200px;
height:200px;
background-color:#99CCFF;
font-size:36px;
font-weight:bold;
}
</style>
<script type="text/javascript">
$(function(){
//设置li最后一个元素的背景色,运用到:last选择器
$("li:last").css("background-color","#EBEBEB");
});
</script>
</head>
<body>
<div>
<ul>
<li>风扇</li>
<li>空调</li>
<li>冰箱</li>
<li>电脑</li>
<li>电视机</li>
<li>洗衣机</li>
<li>微波炉</li>
</ul>
</div>
</body>
</html>
(2)结果如下图