Skip to content

Instantly share code, notes, and snippets.

@ilbonzo
Created February 10, 2015 09:53
Show Gist options
  • Save ilbonzo/6250af652da35c4960e8 to your computer and use it in GitHub Desktop.
Save ilbonzo/6250af652da35c4960e8 to your computer and use it in GitHub Desktop.
get siblings of element without jquery
var getSiblings = function (elem) {
var n = elem.parentNode.firstChild;
var r = [];
for (; n; n = n.nextSibling) {
if (n.nodeType === 1 && n !== elem) {
r.push(n);
}
}
return r;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment