获取兄弟元素的方法

1.next();获取的是当前元素的下一个兄弟元素

$(this).next().css("backgroundColor","green");

 

2.nextAll();获取的是当前元素的后面的所有的兄弟元素

$(this).nextAll().css("backgroundColor","green");

 

3.prev();获取的是当前元素的前一个兄弟元素

$(this).prev().css("backgroundColor","green");

 

4.prevAll();获取的是当前元素的前面的所有的兄弟元素

$(this).prevAll().css("backgroundColor","green");

 

5.siblings();获取的是当前元素的所有的兄弟元素(自己除外)

$(this).siblings().css("backgroundColor","green");

 

posted @ 2017-10-08 15:38  曦阳~  阅读(3261)  评论(0)    收藏  举报