add(expr)
对当前匹配元素集合增加新的匹配元素集合‘expr’,形成新的匹配元素集合
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div").css("border", "2px solid red")
.add("p")
.css("background", "yellow");
});
</script>
<style>
div { width:60px; height:60px; margin:10px; float:left; }
p { clear:left; font-weight:bold; font-size:16px;
color:blue; margin:0 10px; padding:2px; }
</style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p>Added this... (notice no border)</p>
</body>
</html>
$("div").css("border", "2px solid red")
.add("p")
.css("background", "yellow");
对div元素集合增加p元素集合,形成新的元素集合。以下是新的元素集合
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p>Added this... (notice no border)</p>