日期:2014-05-17 浏览次数:20759 次
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>无标题文档</title>
<style type="text/css">
p:first-child { background-color:#CCC}
p { background-color:#ABC}
</style>
</head>
<body>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
</body>
</html>
<html>
<head>
<meta charset="gb2312">
<title>无标题文档</title>
<style type="text/css">
.p_detail { background-color:#CCC}
.p_excerpt { background-color:#ABC}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
$("p:first-child").addClass("p_detail")
$("p:not(:first-child)").addClass("p_excerpt")
});
</script>
</head>
<body>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
</body>
</html>