end()方法:
<style type="text/css">
.m1{background:#09C;}
.m2{border:1px solid #000;}
</style>
<script
src="../jquery-1.3.1.min.js"></script>
<script language="javascript">
$(function(){
$("p").find("span").addClass("m1").end().addClass("m2");
})
</script>
</head>
<body>
<p>hello,<span>how</span>
are you?</p>
<span>hello,
</span>how are you?
andSelf()方法:
<style type="text/css">
.m1{background:#09C;}
.m2{border:1px solid #000;}
</style>
<script
src="../jquery-1.3.1.min.js"></script>
<script language="javascript">
$(function(){
$("div").find("p").addClass("m1").andSelf().addClass("m2");
})
</script>
</head>
<body>
<div>
<p>第一张</p>
<p>第二章</p>
</div>