<ul> <li>list item 1</li> <li>list item 2</li> <li class="third-item">list item 3</li> <li>list item 4</li> <li>list item 5</li> </ul> <script> $('li.third-item').siblings().css('background-color', 'red'); </script>
siblings() 查找同胞元素 ,上例:找到class为third-item 的li 的同胞元素,即1245
$('li').siblings('.third-item').css('background-color', 'red'); 先找到所有li 筛选出class为third-item的li,即3
$("p").slice(0, 2).wrapInner("<b></b>");
slice() 把匹配元素集合缩减为指定的指数范围的子集 例:找到p元素的前俩个
$("p").slice(2)
$("p").slice(2,4) 也可起始位置 0开始,不包括结束
$('li').slice(-2, -1)
.css('background-color', 'red'); 可以去负数,表示从后算起