jQuery中(prev + next) 和 (prev ~ siblings)的不同点。
<!DOCTYPE html>
<html>
<head>
<style>
div,span {
display:block;
width:80px;
height:80px;
margin:5px;
background:#bbffaa;
float:left;
font-size:14px;
}
div#small {
width:60px;
height:25px;
font-size:12px;
background:#fab;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div>div (doesn't match since before #prev)</div>
<span id="prev">span#prev</span>
<div>div sibling</div>
<div>div sibling <div id="small">div niece</div></div>
<span>span sibling (not div)</span>
<div>div sibling</div>
<script>
// ~ 代表id"prem"后面的div都要变
$("#prev ~ div").css("border", "3px groove blue");
// + 代表id"prev"后面的第一个div要变
$("#prev + div").css("border", "3px groove blue");
</script>
</body>
</html>
标签:jQuery,span,height,sibling,siblings,div,prev
From: https://blog.51cto.com/u_16179085/6663475