Created
February 10, 2015 09:53
-
-
Save ilbonzo/6250af652da35c4960e8 to your computer and use it in GitHub Desktop.
get siblings of element without jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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