<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>子元素过滤选择器</title>
<script src="jquery-1.8.0.js"></script>
</head>
<style type="text/css">
body{
font-size:12px;
text-align:center;
}
ul{
width:241px;
list-style-type:none;
padding:0px;
}
ul li{
height:23px;
width:60px;
line-height:23px;
float:left;
border-top:solid 1px #000;
border-bottom:solid 1px #000;
margin-bottom:5px;
}
.GetFous{
width:58px;
border:solid 1px #666;
background-color:#eee;
}
</style>
<script type="text/javascript">
/*
$(function(){
$("li:nth-child(2)").addClass("GetFous");
});
$(function(){
$("li:first-child").addClass("GetFous");
});
$(function(){
$("li:last-child").addClass("GetFous");
});
*/
$(function(){
$("li:only-child").addClass("GetFous");
});
</script>
<body>
<ul>
<li>Item 1-0</li>
<li>Item 1-1</li>
<li>Item 1-2</li>
<li>Item 1-3</li>
</ul>
<ul>
<li>Item 2-0</li>
<li>Item 2-1</li>
<li>Item 2-2</li>
<li>Item 2-3</li>
</ul>
<ul>
<li>Item 3-0</li>
</ul>
</body>
</html>
子元素过滤选择器
最新推荐文章于 2022-01-08 09:51:56 发布