添加元素到匹配的元素集合
?? ?<script>
?? ??? ?$(document).ready(function(){
?? ??? ??? ?$("div").add("p").css("background-color","red")
?? ??? ?})
?? ?</script>
?? ?<script>
?? ??? ?$(document).ready(function(){
?? ??? ??? ?// $("div").add("p").css("background-color","red");
?? ??? ??? ?$("div").css("background-color","yellow").add("p").css("border","10px solid green ")
?? ??? ?})
?? ?</script>
?
获得匹配元素集合中每个素的子元素,包括文字和注释节点。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="jQuery.js"></script>
</head>
<body>
<p>hallo <a href="">john</a>,how are you doing?</p>
</body>
<script>
$(document).ready(function(){
$("p").contents().filter(function(){
return this.nodeType!=1;
}).wrap("<b/>")
})
</script>
</html>
?
终止在当前链的最新过滤操作,并返回匹配的元素的以前状态
?? ??? ?$(document).ready(function(){
?? ??? ??? ?$("ul").find(".foo").css("background-color","yellow").end().find(".bar").css("background-color","red");
?? ??? ??? ?
?? ??? ?})
?? ?</script>