JQuery - 孩子和兄弟选择器

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
	  $(document).ready(function(){   
	//$(".person1 div").css("border", "2px solid red");
	//$(".person1 > div").css("border", "2px solid red");
	//$(".person1 + p").css("border", "2px solid red");
	$(".person1 ~ p").css("border", "2px solid red");
 })
</script>
<div id="msg"></div>
<h1>Child and Sibling Selectors example</h1>
<div class="person1">
	<div class="child">
		<div class="grandchild">
			<div class="great-grandchild">
				I'm the great grandchild.
			</div>
			I'm the grandchild.
		</div>
		I'm the first child.
	</div>
 
	<div class="child">
		I'm the second child.
	</div>
 
	<div class="child">
		I'm the third child.
	</div>
	I'm person1
</div>
<p class="person2">I'm person2</p>
<p class="person3">I'm person3</p>


你可能感兴趣的:(JQuery - 孩子和兄弟选择器)