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>

<scriptsrc="http://code.jquery.com/jquery-latest.min.js"></script>

</head>

<body>

<div>div(doesn'tmatchsincebefore#prev)</div>

<spanid="prev">span#prev</span>

<div>divsibling</div>

<div>divsibling<divid="small">divniece</div></div>

<span>spansibling(notdiv)</span>

<div>divsibling</div>

<script>

//~代表id"prem"后面的div都要变

$("#prev~div").css("border","3pxgrooveblue");

//+代表id"prev"后面的第一个div要变

$("#prev+div").css("border","3pxgrooveblue");

</script>

</body>

</html>