Published on

原生JS获取相邻兄弟元素

Authors
  • avatar
    Name
    duluwa.com
    Twitter
function sibling(s) {
  let siblingsArr = []
  let b = s.parentNode.children
  for (let i = 0, bl = b.length; i < bl; i++) {
    if (b[i] !== s) {
      siblingsArr.push(b[i])
    }
  }
  return siblingsArr
}